Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 0 additions & 8 deletions .chronus/changes/checkpylint-2025-0-7-9-44-5.md

This file was deleted.

12 changes: 12 additions & 0 deletions packages/autorest.python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Release

## 6.28.1

### Bug Fixes

- [#3007](https://github.com/Azure/autorest.python/pull/3007) Fix import issues for typespec namespace
- [#3007](https://github.com/Azure/autorest.python/pull/3007) Only import helpers for serialization if input body is not binary
- [#3007](https://github.com/Azure/autorest.python/pull/3007) Unify descriptions for credentials in documentation
- [#3007](https://github.com/Azure/autorest.python/pull/3007) Add type annotations for initialized properties in msrest model inits
- [#3007](https://github.com/Azure/autorest.python/pull/3007) Add mypy typing to operation group inits
- [#3007](https://github.com/Azure/autorest.python/pull/3007) Remove Python2 specific datetime logic from internal serialization.


## 6.28.0

### Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions packages/autorest.python/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@autorest/python",
"version": "6.28.0",
"version": "6.28.1",
"description": "The Python extension for generators in AutoRest.",
"scripts": {
"start": "node ./scripts/run-python3.js ./scripts/start.py",
Expand Down Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "~0.6.2",
"@typespec/http-client-python": "~0.6.5",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,73 +185,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]],
except NameError:
_long_type = int


class UTC(datetime.tzinfo):
"""Time Zone info for handling UTC"""

def utcoffset(self, dt):
"""UTF offset for UTC is 0.

:param datetime.datetime dt: The datetime
:returns: The offset
:rtype: datetime.timedelta
"""
return datetime.timedelta(0)

def tzname(self, dt):
"""Timestamp representation.

:param datetime.datetime dt: The datetime
:returns: The timestamp representation
:rtype: str
"""
return "Z"

def dst(self, dt):
"""No daylight saving for UTC.

:param datetime.datetime dt: The datetime
:returns: The daylight saving time
:rtype: datetime.timedelta
"""
return datetime.timedelta(hours=1)


try:
from datetime import timezone as _FixedOffset # type: ignore
except ImportError: # Python 2.7

class _FixedOffset(datetime.tzinfo): # type: ignore
"""Fixed offset in minutes east from UTC.
Copy/pasted from Python doc
:param datetime.timedelta offset: offset in timedelta format
"""

def __init__(self, offset) -> None:
self.__offset = offset

def utcoffset(self, dt):
return self.__offset

def tzname(self, dt):
return str(self.__offset.total_seconds() / 3600)

def __repr__(self):
return "<FixedOffset {}>".format(self.tzname(None))

def dst(self, dt):
return datetime.timedelta(0)

def __getinitargs__(self):
return (self.__offset,)


try:
from datetime import timezone

TZ_UTC = timezone.utc
except ImportError:
TZ_UTC = UTC() # type: ignore
TZ_UTC = datetime.timezone.utc

_FLATTEN = re.compile(r"(?<!\\)\.")

Expand Down Expand Up @@ -2051,7 +1985,7 @@ def deserialize_rfc(attr):
try:
parsed_date = email.utils.parsedate_tz(attr) # type: ignore
date_obj = datetime.datetime(
*parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60))
*parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60))
)
if not date_obj.tzinfo:
date_obj = date_obj.astimezone(tz=TZ_UTC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
from typing import Any, Callable, Dict, Optional, TypeVar

from azure.core import AsyncPipelineClient
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
Expand All @@ -20,11 +21,13 @@
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.core.tracing.decorator_async import distributed_trace_async

from ..._serialization import Deserializer, Serializer
from ...operations._operations import (
build_http_success_head200_request,
build_http_success_head204_request,
build_http_success_head404_request,
)
from .._configuration import AutoRestHeadTestServiceConfiguration

if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
Expand All @@ -46,10 +49,10 @@ class HttpSuccessOperations:

def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: AutoRestHeadTestServiceConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@distributed_trace_async
async def head200(self, **kwargs: Any) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
from typing import Any, Callable, Dict, Optional, TypeVar

from azure.core import PipelineClient
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
Expand All @@ -20,7 +21,8 @@
from azure.core.rest import HttpRequest, HttpResponse
from azure.core.tracing.decorator import distributed_trace

from .._serialization import Serializer
from .._configuration import AutoRestHeadTestServiceConfiguration
from .._serialization import Deserializer, Serializer

if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
Expand Down Expand Up @@ -66,10 +68,10 @@ class HttpSuccessOperations:

def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: AutoRestHeadTestServiceConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@distributed_trace
def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,73 +185,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]],
except NameError:
_long_type = int


class UTC(datetime.tzinfo):
"""Time Zone info for handling UTC"""

def utcoffset(self, dt):
"""UTF offset for UTC is 0.

:param datetime.datetime dt: The datetime
:returns: The offset
:rtype: datetime.timedelta
"""
return datetime.timedelta(0)

def tzname(self, dt):
"""Timestamp representation.

:param datetime.datetime dt: The datetime
:returns: The timestamp representation
:rtype: str
"""
return "Z"

def dst(self, dt):
"""No daylight saving for UTC.

:param datetime.datetime dt: The datetime
:returns: The daylight saving time
:rtype: datetime.timedelta
"""
return datetime.timedelta(hours=1)


try:
from datetime import timezone as _FixedOffset # type: ignore
except ImportError: # Python 2.7

class _FixedOffset(datetime.tzinfo): # type: ignore
"""Fixed offset in minutes east from UTC.
Copy/pasted from Python doc
:param datetime.timedelta offset: offset in timedelta format
"""

def __init__(self, offset) -> None:
self.__offset = offset

def utcoffset(self, dt):
return self.__offset

def tzname(self, dt):
return str(self.__offset.total_seconds() / 3600)

def __repr__(self):
return "<FixedOffset {}>".format(self.tzname(None))

def dst(self, dt):
return datetime.timedelta(0)

def __getinitargs__(self):
return (self.__offset,)


try:
from datetime import timezone

TZ_UTC = timezone.utc
except ImportError:
TZ_UTC = UTC() # type: ignore
TZ_UTC = datetime.timezone.utc

_FLATTEN = re.compile(r"(?<!\\)\.")

Expand Down Expand Up @@ -2051,7 +1985,7 @@ def deserialize_rfc(attr):
try:
parsed_date = email.utils.parsedate_tz(attr) # type: ignore
date_obj = datetime.datetime(
*parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60))
*parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60))
)
if not date_obj.tzinfo:
date_obj = date_obj.astimezone(tz=TZ_UTC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
from typing import Any, Callable, Dict, Optional, TypeVar

from azure.core import AsyncPipelineClient
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
Expand All @@ -20,11 +21,13 @@
from azure.core.rest import AsyncHttpResponse, HttpRequest
from azure.core.tracing.decorator_async import distributed_trace_async

from ..._serialization import Deserializer, Serializer
from ...operations._operations import (
build_http_success_head200_request,
build_http_success_head204_request,
build_http_success_head404_request,
)
from .._configuration import AutoRestHeadTestServiceConfiguration

if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
Expand All @@ -46,10 +49,10 @@ class HttpSuccessOperations:

def __init__(self, *args, **kwargs) -> None:
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: AutoRestHeadTestServiceConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@distributed_trace_async
async def head200(self, **kwargs: Any) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
from typing import Any, Callable, Dict, Optional, TypeVar

from azure.core import PipelineClient
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
Expand All @@ -20,7 +21,8 @@
from azure.core.rest import HttpRequest, HttpResponse
from azure.core.tracing.decorator import distributed_trace

from .._serialization import Serializer
from .._configuration import AutoRestHeadTestServiceConfiguration
from .._serialization import Deserializer, Serializer

if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
Expand Down Expand Up @@ -66,10 +68,10 @@ class HttpSuccessOperations:

def __init__(self, *args, **kwargs):
input_args = list(args)
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
self._config: AutoRestHeadTestServiceConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@distributed_trace
def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements
Expand Down
Loading
Loading