Skip to content

Commit f9ac6f3

Browse files
author
SDKAuto
committed
CodeGen from PR 31838 in Azure/azure-rest-api-specs
Merge 5ff1bdac4c21802a1401945539a7f7612aac962e into faebe07bdf8bab920fbecdef2426772179984932
1 parent d90e4e4 commit f9ac6f3

18 files changed

+554
-495
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"commit": "fda3d5e4ae4c69aa72ddfdf5ca1b6d5795a03e71",
2+
"commit": "92214b1faaad098434ae37b69fcc896fdf8ecc8c",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
44
"typespec_src": "specification/azurefleet/AzureFleet.Management",
5-
"@azure-tools/typespec-python": "0.35.1"
5+
"@azure-tools/typespec-python": "0.37.0"
66
}

sdk/computefleet/azure-mgmt-computefleet/azure/mgmt/computefleet/__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 ComputeFleetMgmtClient
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 ComputeFleetMgmtClient # 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
"ComputeFleetMgmtClient",
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/computefleet/azure-mgmt-computefleet/azure/mgmt/computefleet/_model_base.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Licensed under the MIT License. See License.txt in the project root for
66
# license information.
77
# --------------------------------------------------------------------------
8-
# pylint: disable=protected-access, arguments-differ, signature-differs, broad-except, too-many-lines
8+
# pylint: disable=protected-access, broad-except
99

1010
import copy
1111
import calendar
@@ -574,7 +574,7 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
574574
def copy(self) -> "Model":
575575
return Model(self.__dict__)
576576

577-
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:
578578
if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated:
579579
# we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping',
580580
# 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object'
@@ -585,8 +585,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
585585
annotations = {
586586
k: v
587587
for mro_class in mros
588-
if hasattr(mro_class, "__annotations__") # pylint: disable=no-member
589-
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()
590590
}
591591
for attr, rf in attr_to_rest_field.items():
592592
rf._module = cls.__module__
@@ -601,8 +601,8 @@ def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: # pylint: di
601601

602602
def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None:
603603
for base in cls.__bases__:
604-
if hasattr(base, "__mapping__"): # pylint: disable=no-member
605-
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
606606

607607
@classmethod
608608
def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]:
@@ -613,7 +613,7 @@ def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField
613613

614614
@classmethod
615615
def _deserialize(cls, data, exist_discriminators):
616-
if not hasattr(cls, "__mapping__"): # pylint: disable=no-member
616+
if not hasattr(cls, "__mapping__"):
617617
return cls(data)
618618
discriminator = cls._get_discriminator(exist_discriminators)
619619
if discriminator is None:
@@ -633,7 +633,7 @@ def _deserialize(cls, data, exist_discriminators):
633633
discriminator_value = data.find(xml_name).text # pyright: ignore
634634
else:
635635
discriminator_value = data.get(discriminator._rest_name)
636-
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
637637
return mapped_cls._deserialize(data, exist_discriminators)
638638

639639
def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]:
@@ -754,7 +754,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
754754
except AttributeError:
755755
model_name = annotation
756756
if module is not None:
757-
annotation = _get_model(module, model_name)
757+
annotation = _get_model(module, model_name) # type: ignore
758758

759759
try:
760760
if module and _is_model(annotation):
@@ -894,6 +894,22 @@ def _deserialize(
894894
return _deserialize_with_callable(deserializer, value)
895895

896896

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+
897913
class _RestField:
898914
def __init__(
899915
self,

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=too-many-lines
12
# --------------------------------------------------------------------------
23
#
34
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -226,7 +227,7 @@ class _FixedOffset(datetime.tzinfo): # type: ignore
226227
:param datetime.timedelta offset: offset in timedelta format
227228
"""
228229

229-
def __init__(self, offset):
230+
def __init__(self, offset) -> None:
230231
self.__offset = offset
231232

232233
def utcoffset(self, dt):
@@ -309,7 +310,7 @@ def _create_xml_node(tag, prefix=None, ns=None):
309310
return ET.Element(tag)
310311

311312

312-
class Model(object):
313+
class Model:
313314
"""Mixin for all client request body/response body models to support
314315
serialization and deserialization.
315316
"""
@@ -506,7 +507,6 @@ def _flatten_subtype(cls, key, objects):
506507
def _classify(cls, response, objects):
507508
"""Check the class _subtype_map for any child classes.
508509
We want to ignore any inherited _subtype_maps.
509-
Remove the polymorphic key from the initial data.
510510
511511
:param dict response: The initial data
512512
:param dict objects: The class objects
@@ -518,7 +518,7 @@ def _classify(cls, response, objects):
518518

519519
if not isinstance(response, ET.Element):
520520
rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1]
521-
subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None)
521+
subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None)
522522
else:
523523
subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response)
524524
if subtype_value:
@@ -563,7 +563,7 @@ def _decode_attribute_map_key(key):
563563
return key.replace("\\.", ".")
564564

565565

566-
class Serializer(object): # pylint: disable=too-many-public-methods
566+
class Serializer: # pylint: disable=too-many-public-methods
567567
"""Request object model serializer."""
568568

569569
basic_types = {str: "str", int: "int", bool: "bool", float: "float"}
@@ -598,7 +598,7 @@ class Serializer(object): # pylint: disable=too-many-public-methods
598598
"multiple": lambda x, y: x % y != 0,
599599
}
600600

601-
def __init__(self, classes: Optional[Mapping[str, type]] = None):
601+
def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None:
602602
self.serialize_type = {
603603
"iso-8601": Serializer.serialize_iso,
604604
"rfc-1123": Serializer.serialize_rfc,
@@ -1441,7 +1441,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
14411441
return children[0]
14421442

14431443

1444-
class Deserializer(object):
1444+
class Deserializer:
14451445
"""Response object model deserializer.
14461446
14471447
:param dict classes: Class type dictionary for deserializing complex types.
@@ -1452,7 +1452,7 @@ class Deserializer(object):
14521452

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

1455-
def __init__(self, classes: Optional[Mapping[str, type]] = None):
1455+
def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None:
14561456
self.deserialize_type = {
14571457
"iso-8601": Deserializer.deserialize_iso,
14581458
"rfc-1123": Deserializer.deserialize_rfc,
@@ -1683,17 +1683,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None):
16831683
subtype = getattr(response, "_subtype_map", {})
16841684
try:
16851685
readonly = [
1686-
k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access
1686+
k
1687+
for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore
1688+
if v.get("readonly")
16871689
]
16881690
const = [
1689-
k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access
1691+
k
1692+
for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore
1693+
if v.get("constant")
16901694
]
16911695
kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const}
16921696
response_obj = response(**kwargs)
16931697
for attr in readonly:
16941698
setattr(response_obj, attr, attrs.get(attr))
16951699
if additional_properties:
1696-
response_obj.additional_properties = additional_properties
1700+
response_obj.additional_properties = additional_properties # type: ignore
16971701
return response_obj
16981702
except TypeError as err:
16991703
msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore

sdk/computefleet/azure-mgmt-computefleet/azure/mgmt/computefleet/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "1.0.0"
9+
VERSION = "1.0.0b1"

sdk/computefleet/azure-mgmt-computefleet/azure/mgmt/computefleet/aio/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@
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 ComputeFleetMgmtClient
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 ComputeFleetMgmtClient # type: ignore
1016

1117
try:
1218
from ._patch import __all__ as _patch_all
13-
from ._patch import * # pylint: disable=unused-wildcard-import
19+
from ._patch import *
1420
except ImportError:
1521
_patch_all = []
1622
from ._patch import patch_sdk as _patch_sdk
1723

1824
__all__ = [
1925
"ComputeFleetMgmtClient",
2026
]
21-
__all__.extend([p for p in _patch_all if p not in __all__])
27+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2228

2329
_patch_sdk()

sdk/computefleet/azure-mgmt-computefleet/azure/mgmt/computefleet/aio/operations/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@
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 ._operations import Operations
10-
from ._operations import FleetsOperations
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._operations import Operations # type: ignore
16+
from ._operations import FleetsOperations # type: ignore
1117

1218
from ._patch import __all__ as _patch_all
13-
from ._patch import * # pylint: disable=unused-wildcard-import
19+
from ._patch import *
1420
from ._patch import patch_sdk as _patch_sdk
1521

1622
__all__ = [
1723
"Operations",
1824
"FleetsOperations",
1925
]
20-
__all__.extend([p for p in _patch_all if p not in __all__])
26+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2127
_patch_sdk()

sdk/computefleet/azure-mgmt-computefleet/azure/mgmt/computefleet/aio/operations/_operations.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling
3434

3535
from ... import models as _models
36-
from ..._model_base import SdkJSONEncoder, _deserialize
36+
from ..._model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize
3737
from ...operations._operations import (
3838
build_fleets_create_or_update_request,
3939
build_fleets_delete_request,
@@ -147,7 +147,7 @@ async def get_next(next_link=None):
147147

148148
if response.status_code not in [200]:
149149
map_error(status_code=response.status_code, response=response, error_map=error_map)
150-
error = _deserialize(_models.ErrorResponse, response.json())
150+
error = _failsafe_deserialize(_models.ErrorResponse, response.json())
151151
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
152152

153153
return pipeline_response
@@ -225,7 +225,7 @@ async def get(self, resource_group_name: str, fleet_name: str, **kwargs: Any) ->
225225
except (StreamConsumedError, StreamClosedError):
226226
pass
227227
map_error(status_code=response.status_code, response=response, error_map=error_map)
228-
error = _deserialize(_models.ErrorResponse, response.json())
228+
error = _failsafe_deserialize(_models.ErrorResponse, response.json())
229229
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
230230

231231
if _stream:
@@ -290,7 +290,7 @@ async def _create_or_update_initial(
290290
except (StreamConsumedError, StreamClosedError):
291291
pass
292292
map_error(status_code=response.status_code, response=response, error_map=error_map)
293-
error = _deserialize(_models.ErrorResponse, response.json())
293+
error = _failsafe_deserialize(_models.ErrorResponse, response.json())
294294
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
295295

296296
response_headers = {}
@@ -515,7 +515,7 @@ async def _update_initial(
515515
except (StreamConsumedError, StreamClosedError):
516516
pass
517517
map_error(status_code=response.status_code, response=response, error_map=error_map)
518-
error = _deserialize(_models.ErrorResponse, response.json())
518+
error = _failsafe_deserialize(_models.ErrorResponse, response.json())
519519
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
520520

521521
response_headers = {}
@@ -729,7 +729,7 @@ async def _delete_initial(self, resource_group_name: str, fleet_name: str, **kwa
729729
except (StreamConsumedError, StreamClosedError):
730730
pass
731731
map_error(status_code=response.status_code, response=response, error_map=error_map)
732-
error = _deserialize(_models.ErrorResponse, response.json())
732+
error = _failsafe_deserialize(_models.ErrorResponse, response.json())
733733
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
734734

735735
response_headers = {}
@@ -882,7 +882,7 @@ async def get_next(next_link=None):
882882

883883
if response.status_code not in [200]:
884884
map_error(status_code=response.status_code, response=response, error_map=error_map)
885-
error = _deserialize(_models.ErrorResponse, response.json())
885+
error = _failsafe_deserialize(_models.ErrorResponse, response.json())
886886
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
887887

888888
return pipeline_response
@@ -966,7 +966,7 @@ async def get_next(next_link=None):
966966

967967
if response.status_code not in [200]:
968968
map_error(status_code=response.status_code, response=response, error_map=error_map)
969-
error = _deserialize(_models.ErrorResponse, response.json())
969+
error = _failsafe_deserialize(_models.ErrorResponse, response.json())
970970
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
971971

972972
return pipeline_response
@@ -1060,7 +1060,7 @@ async def get_next(next_link=None):
10601060

10611061
if response.status_code not in [200]:
10621062
map_error(status_code=response.status_code, response=response, error_map=error_map)
1063-
error = _deserialize(_models.ErrorResponse, response.json())
1063+
error = _failsafe_deserialize(_models.ErrorResponse, response.json())
10641064
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
10651065

10661066
return pipeline_response

0 commit comments

Comments
 (0)