Skip to content

Commit 8a94a9b

Browse files
author
SDKAuto
committed
CodeGen from PR 32092 in Azure/azure-rest-api-specs
Merge 36c79d6cfbcadcef92748fd5c7d66f72e4c45bad into a2f4089b0e0c33d038579a80c23b470d94aeb99a
1 parent ea869d8 commit 8a94a9b

File tree

41 files changed

+636
-1045
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+636
-1045
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"commit": "4883fa5dbf6f2c9093fac8ce334547e9dfac68fa",
2+
"commit": "4b0caba797fff8f3d58c145e1f958141b2e67935",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
44
"typespec_src": "specification/computeschedule/ComputeSchedule.Management",
5-
"@azure-tools/typespec-python": "0.33.0"
5+
"@azure-tools/typespec-python": "0.38.1"
66
}

sdk/computeschedule/azure-mgmt-computeschedule/azure/mgmt/computeschedule/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@
55
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._client import ComputeScheduleMgmtClient
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import ComputeScheduleMgmtClient # type: ignore
1016
from ._version import VERSION
1117

1218
__version__ = VERSION
1319

1420
try:
1521
from ._patch import __all__ as _patch_all
16-
from ._patch import * # pylint: disable=unused-wildcard-import
22+
from ._patch import *
1723
except ImportError:
1824
_patch_all = []
1925
from ._patch import patch_sdk as _patch_sdk
2026

2127
__all__ = [
2228
"ComputeScheduleMgmtClient",
2329
]
24-
__all__.extend([p for p in _patch_all if p not in __all__])
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2531

2632
_patch_sdk()

sdk/computeschedule/azure-mgmt-computeschedule/azure/mgmt/computeschedule/_client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
from .operations import Operations, ScheduledActionsOperations
2121

2222
if TYPE_CHECKING:
23-
# pylint: disable=unused-import,ungrouped-imports
2423
from azure.core.credentials import TokenCredential
2524

2625

27-
class ComputeScheduleMgmtClient: # pylint: disable=client-accepts-api-version-keyword
26+
class ComputeScheduleMgmtClient:
2827
"""Microsoft.ComputeSchedule Resource Provider management API.
2928
3029
:ivar operations: Operations operations
@@ -37,9 +36,8 @@ class ComputeScheduleMgmtClient: # pylint: disable=client-accepts-api-version-k
3736
:type subscription_id: str
3837
:param base_url: Service host. Default value is "https://management.azure.com".
3938
:type base_url: str
40-
:keyword api_version: The API version to use for this operation. Default value is
41-
"2024-08-15-preview". Note that overriding this default value may result in unsupported
42-
behavior.
39+
:keyword api_version: The API version to use for this operation. Default value is "2024-10-01".
40+
Note that overriding this default value may result in unsupported behavior.
4341
:paramtype api_version: str
4442
"""
4543

sdk/computeschedule/azure-mgmt-computeschedule/azure/mgmt/computeschedule/_configuration.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
from ._version import VERSION
1515

1616
if TYPE_CHECKING:
17-
# pylint: disable=unused-import,ungrouped-imports
1817
from azure.core.credentials import TokenCredential
1918

2019

21-
class ComputeScheduleMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
20+
class ComputeScheduleMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes
2221
"""Configuration for ComputeScheduleMgmtClient.
2322
2423
Note that all parameters used to create this instance are saved as instance
@@ -30,9 +29,8 @@ class ComputeScheduleMgmtClientConfiguration: # pylint: disable=too-many-instan
3029
:type subscription_id: str
3130
:param base_url: Service host. Default value is "https://management.azure.com".
3231
:type base_url: str
33-
:keyword api_version: The API version to use for this operation. Default value is
34-
"2024-08-15-preview". Note that overriding this default value may result in unsupported
35-
behavior.
32+
:keyword api_version: The API version to use for this operation. Default value is "2024-10-01".
33+
Note that overriding this default value may result in unsupported behavior.
3634
:paramtype api_version: str
3735
"""
3836

@@ -43,7 +41,7 @@ def __init__(
4341
base_url: str = "https://management.azure.com",
4442
**kwargs: Any
4543
) -> None:
46-
api_version: str = kwargs.pop("api_version", "2024-08-15-preview")
44+
api_version: str = kwargs.pop("api_version", "2024-10-01")
4745

4846
if credential is None:
4947
raise ValueError("Parameter 'credential' must not be None.")

sdk/computeschedule/azure-mgmt-computeschedule/azure/mgmt/computeschedule/_model_base.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
# pylint: disable=too-many-lines
12
# coding=utf-8
23
# --------------------------------------------------------------------------
34
# Copyright (c) Microsoft Corporation. All rights reserved.
45
# Licensed under the MIT License. See License.txt in the project root for
56
# license information.
67
# --------------------------------------------------------------------------
7-
# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines
8+
# pylint: disable=protected-access, broad-except
89

910
import copy
1011
import calendar
@@ -573,7 +574,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
573574
def copy(self) -> "Model":
574575
return Model(self.__dict__)
575576

576-
def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: disable=unused-argument
577+
def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self:
577578
if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated:
578579
# we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping',
579580
# 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object'
@@ -584,8 +585,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
584585
annotations = {
585586
k: v
586587
for mro_class in mros
587-
if hasattr(mro_class, "__annotations__") # pylint: disable=no-member
588-
for k, v in mro_class.__annotations__.items() # pylint: disable=no-member
588+
if hasattr(mro_class, "__annotations__")
589+
for k, v in mro_class.__annotations__.items()
589590
}
590591
for attr, rf in attr_to_rest_field.items():
591592
rf._module = cls.__module__
@@ -600,8 +601,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
600601

601602
def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None:
602603
for base in cls.__bases__:
603-
if hasattr(base, "__mapping__"): # pylint: disable=no-member
604-
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member
604+
if hasattr(base, "__mapping__"):
605+
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore
605606

606607
@classmethod
607608
def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]:
@@ -612,7 +613,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField
612613

613614
@classmethod
614615
def _deserialize(cls, data, exist_discriminators):
615-
if not hasattr(cls, "__mapping__"): # pylint: disable=no-member
616+
if not hasattr(cls, "__mapping__"):
616617
return cls(data)
617618
discriminator = cls._get_discriminator(exist_discriminators)
618619
if discriminator is None:
@@ -632,11 +633,11 @@ def _deserialize(cls, data, exist_discriminators):
632633
discriminator_value = data.find(xml_name).text # pyright: ignore
633634
else:
634635
discriminator_value = data.get(discriminator._rest_name)
635-
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member
636+
mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore
636637
return mapped_cls._deserialize(data, exist_discriminators)
637638

638639
def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]:
639-
"""Return a dict that can be JSONify using json.dump.
640+
"""Return a dict that can be turned into json using json.dump.
640641
641642
:keyword bool exclude_readonly: Whether to remove the readonly properties.
642643
:returns: A dict JSON compatible object
@@ -733,7 +734,7 @@ def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.An
733734
)
734735

735736

736-
def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915, R0912
737+
def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches
737738
annotation: typing.Any,
738739
module: typing.Optional[str],
739740
rf: typing.Optional["_RestField"] = None,
@@ -753,7 +754,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915,
753754
except AttributeError:
754755
model_name = annotation
755756
if module is not None:
756-
annotation = _get_model(module, model_name)
757+
annotation = _get_model(module, model_name) # type: ignore
757758

758759
try:
759760
if module and _is_model(annotation):
@@ -893,6 +894,22 @@ def _deserialize(
893894
return _deserialize_with_callable(deserializer, value)
894895

895896

897+
def _failsafe_deserialize(
898+
deserializer: typing.Any,
899+
value: typing.Any,
900+
module: typing.Optional[str] = None,
901+
rf: typing.Optional["_RestField"] = None,
902+
format: typing.Optional[str] = None,
903+
) -> typing.Any:
904+
try:
905+
return _deserialize(deserializer, value, module, rf, format)
906+
except DeserializationError:
907+
_LOGGER.warning(
908+
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
909+
)
910+
return None
911+
912+
896913
class _RestField:
897914
def __init__(
898915
self,

sdk/computeschedule/azure-mgmt-computeschedule/azure/mgmt/computeschedule/_serialization.py

Lines changed: 15 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -185,73 +185,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]],
185185
except NameError:
186186
_long_type = int
187187

188-
189-
class UTC(datetime.tzinfo):
190-
"""Time Zone info for handling UTC"""
191-
192-
def utcoffset(self, dt):
193-
"""UTF offset for UTC is 0.
194-
195-
:param datetime.datetime dt: The datetime
196-
:returns: The offset
197-
:rtype: datetime.timedelta
198-
"""
199-
return datetime.timedelta(0)
200-
201-
def tzname(self, dt):
202-
"""Timestamp representation.
203-
204-
:param datetime.datetime dt: The datetime
205-
:returns: The timestamp representation
206-
:rtype: str
207-
"""
208-
return "Z"
209-
210-
def dst(self, dt):
211-
"""No daylight saving for UTC.
212-
213-
:param datetime.datetime dt: The datetime
214-
:returns: The daylight saving time
215-
:rtype: datetime.timedelta
216-
"""
217-
return datetime.timedelta(hours=1)
218-
219-
220-
try:
221-
from datetime import timezone as _FixedOffset # type: ignore
222-
except ImportError: # Python 2.7
223-
224-
class _FixedOffset(datetime.tzinfo): # type: ignore
225-
"""Fixed offset in minutes east from UTC.
226-
Copy/pasted from Python doc
227-
:param datetime.timedelta offset: offset in timedelta format
228-
"""
229-
230-
def __init__(self, offset):
231-
self.__offset = offset
232-
233-
def utcoffset(self, dt):
234-
return self.__offset
235-
236-
def tzname(self, dt):
237-
return str(self.__offset.total_seconds() / 3600)
238-
239-
def __repr__(self):
240-
return "<FixedOffset {}>".format(self.tzname(None))
241-
242-
def dst(self, dt):
243-
return datetime.timedelta(0)
244-
245-
def __getinitargs__(self):
246-
return (self.__offset,)
247-
248-
249-
try:
250-
from datetime import timezone
251-
252-
TZ_UTC = timezone.utc
253-
except ImportError:
254-
TZ_UTC = UTC() # type: ignore
188+
TZ_UTC = datetime.timezone.utc
255189

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

@@ -310,7 +244,7 @@ def _create_xml_node(tag, prefix=None, ns=None):
310244
return ET.Element(tag)
311245

312246

313-
class Model(object):
247+
class Model:
314248
"""Mixin for all client request body/response body models to support
315249
serialization and deserialization.
316250
"""
@@ -507,7 +441,6 @@ def _flatten_subtype(cls, key, objects):
507441
def _classify(cls, response, objects):
508442
"""Check the class _subtype_map for any child classes.
509443
We want to ignore any inherited _subtype_maps.
510-
Remove the polymorphic key from the initial data.
511444
512445
:param dict response: The initial data
513446
:param dict objects: The class objects
@@ -519,7 +452,7 @@ def _classify(cls, response, objects):
519452

520453
if not isinstance(response, ET.Element):
521454
rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1]
522-
subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None)
455+
subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None)
523456
else:
524457
subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response)
525458
if subtype_value:
@@ -564,7 +497,7 @@ def _decode_attribute_map_key(key):
564497
return key.replace("\\.", ".")
565498

566499

567-
class Serializer(object): # pylint: disable=too-many-public-methods
500+
class Serializer: # pylint: disable=too-many-public-methods
568501
"""Request object model serializer."""
569502

570503
basic_types = {str: "str", int: "int", bool: "bool", float: "float"}
@@ -599,7 +532,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods
599532
"multiple": lambda x, y: x % y != 0,
600533
}
601534

602-
def __init__(self, classes: Optional[Mapping[str, type]] = None):
535+
def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None:
603536
self.serialize_type = {
604537
"iso-8601": Serializer.serialize_iso,
605538
"rfc-1123": Serializer.serialize_rfc,
@@ -1442,7 +1375,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
14421375
return children[0]
14431376

14441377

1445-
class Deserializer(object):
1378+
class Deserializer:
14461379
"""Response object model deserializer.
14471380
14481381
:param dict classes: Class type dictionary for deserializing complex types.
@@ -1453,7 +1386,7 @@ class Deserializer(object):
14531386

14541387
valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?")
14551388

1456-
def __init__(self, classes: Optional[Mapping[str, type]] = None):
1389+
def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None:
14571390
self.deserialize_type = {
14581391
"iso-8601": Deserializer.deserialize_iso,
14591392
"rfc-1123": Deserializer.deserialize_rfc,
@@ -1684,17 +1617,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None):
16841617
subtype = getattr(response, "_subtype_map", {})
16851618
try:
16861619
readonly = [
1687-
k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access
1620+
k
1621+
for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore
1622+
if v.get("readonly")
16881623
]
16891624
const = [
1690-
k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access
1625+
k
1626+
for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore
1627+
if v.get("constant")
16911628
]
16921629
kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const}
16931630
response_obj = response(**kwargs)
16941631
for attr in readonly:
16951632
setattr(response_obj, attr, attrs.get(attr))
16961633
if additional_properties:
1697-
response_obj.additional_properties = additional_properties
1634+
response_obj.additional_properties = additional_properties # type: ignore
16981635
return response_obj
16991636
except TypeError as err:
17001637
msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore
@@ -2048,7 +1985,7 @@ def deserialize_rfc(attr):
20481985
try:
20491986
parsed_date = email.utils.parsedate_tz(attr) # type: ignore
20501987
date_obj = datetime.datetime(
2051-
*parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60))
1988+
*parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60))
20521989
)
20531990
if not date_obj.tzinfo:
20541991
date_obj = date_obj.astimezone(tz=TZ_UTC)

0 commit comments

Comments
 (0)