@autorest/python 6.3.0 → 6.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/autorest/codegen/templates/client.py.jinja2 +1 -1
- package/autorest/codegen/templates/model_base.py.jinja2 +18 -14
- package/autorest/codegen/templates/model_dpg.py.jinja2 +1 -1
- package/autorest/preprocess/__init__.py +3 -3
- package/package.json +4 -4
- package/requirements.txt +0 -1
package/README.md
CHANGED
|
@@ -215,5 +215,5 @@ help-content:
|
|
|
215
215
|
|
|
216
216
|
<!-- LINKS -->
|
|
217
217
|
|
|
218
|
-
[python_docs]: https://github.com/Azure/autorest.python/tree/
|
|
218
|
+
[python_docs]: https://github.com/Azure/autorest.python/tree/main/docs/readme.md
|
|
219
219
|
[main_docs]: https://github.com/Azure/autorest/tree/master/docs
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
{{ keywords.await }}self._client.__{{ keywords.async_prefix }}enter__()
|
|
34
34
|
return self
|
|
35
35
|
|
|
36
|
-
{{ keywords.def }} __{{ keywords.async_prefix }}exit__(self, *exc_details) -> None:
|
|
36
|
+
{{ keywords.def }} __{{ keywords.async_prefix }}exit__(self, *exc_details: Any) -> None:
|
|
37
37
|
{{ keywords.await }}self._client.__{{ keywords.async_prefix }}exit__(*exc_details)
|
|
@@ -14,7 +14,6 @@ import base64
|
|
|
14
14
|
import re
|
|
15
15
|
import copy
|
|
16
16
|
import typing
|
|
17
|
-
from collections.abc import MutableMapping
|
|
18
17
|
from datetime import datetime, date, time, timedelta, timezone
|
|
19
18
|
from json import JSONEncoder
|
|
20
19
|
import isodate
|
|
@@ -23,6 +22,11 @@ from azure.core import CaseInsensitiveEnumMeta
|
|
|
23
22
|
from azure.core.pipeline import PipelineResponse
|
|
24
23
|
from azure.core.serialization import NULL as AzureCoreNull
|
|
25
24
|
|
|
25
|
+
if sys.version_info >= (3, 9):
|
|
26
|
+
from collections.abc import MutableMapping
|
|
27
|
+
else:
|
|
28
|
+
from typing import MutableMapping
|
|
29
|
+
|
|
26
30
|
_LOGGER = logging.getLogger(__name__)
|
|
27
31
|
|
|
28
32
|
__all__ = ["NULL", "AzureJSONEncoder", "Model", "rest_field", "rest_discriminator"]
|
|
@@ -276,7 +280,7 @@ def _get_model(module_name: str, model_name: str):
|
|
|
276
280
|
_UNSET = object()
|
|
277
281
|
|
|
278
282
|
|
|
279
|
-
class _MyMutableMapping(MutableMapping):
|
|
283
|
+
class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object
|
|
280
284
|
def __init__(self, data: typing.Dict[str, typing.Any]) -> None:
|
|
281
285
|
self._data = copy.deepcopy(data)
|
|
282
286
|
|
|
@@ -301,13 +305,13 @@ class _MyMutableMapping(MutableMapping):
|
|
|
301
305
|
def __ne__(self, other: typing.Any) -> bool:
|
|
302
306
|
return not self.__eq__(other)
|
|
303
307
|
|
|
304
|
-
def keys(self) -> typing.KeysView:
|
|
308
|
+
def keys(self) -> typing.KeysView[str]:
|
|
305
309
|
return self._data.keys()
|
|
306
310
|
|
|
307
|
-
def values(self) -> typing.ValuesView:
|
|
311
|
+
def values(self) -> typing.ValuesView[typing.Any]:
|
|
308
312
|
return self._data.values()
|
|
309
313
|
|
|
310
|
-
def items(self) -> typing.ItemsView:
|
|
314
|
+
def items(self) -> typing.ItemsView[str, typing.Any]:
|
|
311
315
|
return self._data.items()
|
|
312
316
|
|
|
313
317
|
def get(self, key: str, default: typing.Any = None) -> typing.Any:
|
|
@@ -399,7 +403,7 @@ def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typin
|
|
|
399
403
|
class Model(_MyMutableMapping):
|
|
400
404
|
_is_model = True
|
|
401
405
|
|
|
402
|
-
def __init__(self, *args, **kwargs):
|
|
406
|
+
def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
|
|
403
407
|
class_name = self.__class__.__name__
|
|
404
408
|
if len(args) > 1:
|
|
405
409
|
raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given")
|
|
@@ -420,10 +424,10 @@ class Model(_MyMutableMapping):
|
|
|
420
424
|
dict_to_pass.update({self._attr_to_rest_field[k]._rest_name: _serialize(v) for k, v in kwargs.items()})
|
|
421
425
|
super().__init__(dict_to_pass)
|
|
422
426
|
|
|
423
|
-
def copy(self):
|
|
427
|
+
def copy(self) -> "Model":
|
|
424
428
|
return Model(self.__dict__)
|
|
425
429
|
|
|
426
|
-
def __new__(cls, *args: typing.Any, **kwargs: typing.Any): # pylint: disable=unused-argument
|
|
430
|
+
def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> "Model": # pylint: disable=unused-argument
|
|
427
431
|
# we know the last three classes in mro are going to be 'Model', 'dict', and 'object'
|
|
428
432
|
mros = cls.__mro__[:-3][::-1] # ignore model, dict, and object parents, and reverse the mro order
|
|
429
433
|
attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property
|
|
@@ -443,12 +447,12 @@ class Model(_MyMutableMapping):
|
|
|
443
447
|
rf._rest_name_input = attr
|
|
444
448
|
cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items())
|
|
445
449
|
|
|
446
|
-
return super().__new__(cls)
|
|
450
|
+
return super().__new__(cls) # pylint: disable=no-value-for-parameter
|
|
447
451
|
|
|
448
|
-
def __init_subclass__(cls, discriminator=None):
|
|
452
|
+
def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None:
|
|
449
453
|
for base in cls.__bases__:
|
|
450
454
|
if hasattr(base, "__mapping__"): # pylint: disable=no-member
|
|
451
|
-
base.__mapping__[discriminator or cls.__name__] = cls # pylint: disable=no-member
|
|
455
|
+
base.__mapping__[discriminator or cls.__name__] = cls # type: ignore # pylint: disable=no-member
|
|
452
456
|
|
|
453
457
|
@classmethod
|
|
454
458
|
def _get_discriminator(cls) -> typing.Optional[str]:
|
|
@@ -469,7 +473,7 @@ class Model(_MyMutableMapping):
|
|
|
469
473
|
|
|
470
474
|
|
|
471
475
|
def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements
|
|
472
|
-
annotation: typing.Any, module: typing.Optional[str], rf: "_RestField" = None
|
|
476
|
+
annotation: typing.Any, module: typing.Optional[str], rf: typing.Optional["_RestField"] = None
|
|
473
477
|
) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]:
|
|
474
478
|
if not annotation or annotation in [int, float]:
|
|
475
479
|
return None
|
|
@@ -620,8 +624,8 @@ def _deserialize_with_callable(deserializer: typing.Optional[typing.Callable[[ty
|
|
|
620
624
|
# for unknown value, return raw value
|
|
621
625
|
return value
|
|
622
626
|
if isinstance(deserializer, type) and issubclass(deserializer, Model):
|
|
623
|
-
return deserializer._deserialize(value)
|
|
624
|
-
return deserializer(value)
|
|
627
|
+
return deserializer._deserialize(value)
|
|
628
|
+
return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value)
|
|
625
629
|
except Exception as e:
|
|
626
630
|
raise DeserializationError() from e
|
|
627
631
|
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
{% endif %}
|
|
57
57
|
{% set initialize_properties = serializer.initialize_properties(model) %}
|
|
58
58
|
{% if model.is_public and serializer.init_line(model) or initialize_properties %}
|
|
59
|
-
def __init__(self, *args, **kwargs):{{ '# pylint: disable=useless-super-delegation' if not initialize_properties else '' }}
|
|
59
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:{{ '# pylint: disable=useless-super-delegation' if not initialize_properties else '' }}
|
|
60
60
|
super().__init__(*args, **kwargs)
|
|
61
61
|
{% for initialize_property in initialize_properties %}
|
|
62
62
|
{{ initialize_property }}
|
|
@@ -178,9 +178,9 @@ def update_parameter(yaml_data: Dict[str, Any]) -> None:
|
|
|
178
178
|
if yaml_data.get("propertyToParameterName"):
|
|
179
179
|
# need to create a new one with padded keys and values
|
|
180
180
|
yaml_data["propertyToParameterName"] = {
|
|
181
|
-
pad_reserved_words(prop, PadType.PROPERTY)
|
|
182
|
-
|
|
183
|
-
)
|
|
181
|
+
pad_reserved_words(prop, PadType.PROPERTY)
|
|
182
|
+
.lower(): pad_reserved_words(param_name, PadType.PARAMETER)
|
|
183
|
+
.lower()
|
|
184
184
|
for prop, param_name in yaml_data["propertyToParameterName"].items()
|
|
185
185
|
}
|
|
186
186
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.2",
|
|
4
4
|
"description": "The Python extension for generators in AutoRest.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/Azure/autorest.python/tree/
|
|
8
|
+
"url": "https://github.com/Azure/autorest.python/tree/main"
|
|
9
9
|
},
|
|
10
|
-
"readme": "https://github.com/Azure/autorest.python/blob/
|
|
10
|
+
"readme": "https://github.com/Azure/autorest.python/blob/main/README.md",
|
|
11
11
|
"keywords": [
|
|
12
12
|
"autorest",
|
|
13
13
|
"python"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/Azure/autorest.python/issues"
|
|
19
19
|
},
|
|
20
|
-
"homepage": "https://github.com/Azure/autorest.python/blob/
|
|
20
|
+
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@autorest/system-requirements": "~1.0.0"
|
|
23
23
|
},
|