@autorest/python 6.28.0 → 6.28.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/autorest/codegen.py +2 -2
- package/autorest/jsonrpc/__init__.py +2 -2
- package/autorest/m4reformatter/__init__.py +13 -13
- package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +1 -1
- package/generator/build/lib/pygen/codegen/models/code_model.py +5 -1
- package/generator/build/lib/pygen/codegen/models/combined_type.py +4 -3
- package/generator/build/lib/pygen/codegen/models/credential_types.py +4 -0
- package/generator/build/lib/pygen/codegen/models/operation.py +9 -3
- package/generator/build/lib/pygen/codegen/models/operation_group.py +26 -1
- package/generator/build/lib/pygen/codegen/models/paging_operation.py +1 -1
- package/generator/build/lib/pygen/codegen/models/property.py +2 -2
- package/generator/build/lib/pygen/codegen/serializers/__init__.py +22 -7
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +14 -3
- package/generator/build/lib/pygen/codegen/serializers/model_serializer.py +2 -1
- package/generator/build/lib/pygen/codegen/serializers/operation_groups_serializer.py +1 -0
- package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +61 -0
- package/generator/build/lib/pygen/codegen/templates/operation_group.py.jinja2 +4 -4
- package/generator/build/lib/pygen/codegen/templates/operation_groups_container.py.jinja2 +2 -0
- package/generator/build/lib/pygen/codegen/templates/serialization.py.jinja2 +39 -107
- package/generator/build/lib/pygen/preprocess/__init__.py +1 -1
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/code_model.py +5 -1
- package/generator/pygen/codegen/models/combined_type.py +4 -3
- package/generator/pygen/codegen/models/credential_types.py +4 -0
- package/generator/pygen/codegen/models/operation.py +9 -3
- package/generator/pygen/codegen/models/operation_group.py +26 -1
- package/generator/pygen/codegen/models/paging_operation.py +1 -1
- package/generator/pygen/codegen/models/property.py +2 -2
- package/generator/pygen/codegen/serializers/__init__.py +22 -7
- package/generator/pygen/codegen/serializers/builder_serializer.py +14 -3
- package/generator/pygen/codegen/serializers/model_serializer.py +2 -1
- package/generator/pygen/codegen/serializers/operation_groups_serializer.py +1 -0
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +61 -0
- package/generator/pygen/codegen/templates/operation_group.py.jinja2 +4 -4
- package/generator/pygen/codegen/templates/operation_groups_container.py.jinja2 +2 -0
- package/generator/pygen/codegen/templates/serialization.py.jinja2 +39 -107
- package/generator/pygen/preprocess/__init__.py +1 -1
- package/package.json +2 -2
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
- package/scripts/eng/mypy.ini +1 -1
- package/scripts/mypy.ini +1 -1
- package/scripts/prepare.py +2 -2
- package/scripts/start.py +2 -2
- package/scripts/venvtools.py +2 -2
|
@@ -192,7 +192,8 @@ class MsrestModelSerializer(_ModelSerializer):
|
|
|
192
192
|
if prop.is_discriminator:
|
|
193
193
|
init_args.append(self.initialize_discriminator_property(model, prop))
|
|
194
194
|
elif prop.readonly:
|
|
195
|
-
|
|
195
|
+
# we want typing for readonly since typing isn't provided from the command line
|
|
196
|
+
init_args.append(f"self.{prop.client_name}: {prop.type_annotation()} = None")
|
|
196
197
|
elif not prop.constant:
|
|
197
198
|
init_args.append(f"self.{prop.client_name} = {prop.client_name}")
|
|
198
199
|
return init_args
|
|
@@ -372,15 +372,34 @@ class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=uns
|
|
|
372
372
|
return not self.__eq__(other)
|
|
373
373
|
|
|
374
374
|
def keys(self) -> typing.KeysView[str]:
|
|
375
|
+
"""
|
|
376
|
+
:returns: a set-like object providing a view on D's keys
|
|
377
|
+
:rtype: ~typing.KeysView
|
|
378
|
+
"""
|
|
375
379
|
return self._data.keys()
|
|
376
380
|
|
|
377
381
|
def values(self) -> typing.ValuesView[typing.Any]:
|
|
382
|
+
"""
|
|
383
|
+
:returns: an object providing a view on D's values
|
|
384
|
+
:rtype: ~typing.ValuesView
|
|
385
|
+
"""
|
|
378
386
|
return self._data.values()
|
|
379
387
|
|
|
380
388
|
def items(self) -> typing.ItemsView[str, typing.Any]:
|
|
389
|
+
"""
|
|
390
|
+
:returns: set-like object providing a view on D's items
|
|
391
|
+
:rtype: ~typing.ItemsView
|
|
392
|
+
"""
|
|
381
393
|
return self._data.items()
|
|
382
394
|
|
|
383
395
|
def get(self, key: str, default: typing.Any = None) -> typing.Any:
|
|
396
|
+
"""
|
|
397
|
+
Get the value for key if key is in the dictionary, else default.
|
|
398
|
+
:param str key: The key to look up.
|
|
399
|
+
:param any default: The value to return if key is not in the dictionary. Defaults to None
|
|
400
|
+
:returns: D[k] if k in D, else d.
|
|
401
|
+
:rtype: any
|
|
402
|
+
"""
|
|
384
403
|
try:
|
|
385
404
|
return self[key]
|
|
386
405
|
except KeyError:
|
|
@@ -396,17 +415,38 @@ class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=uns
|
|
|
396
415
|
def pop(self, key: str, default: typing.Any) -> typing.Any: ...
|
|
397
416
|
|
|
398
417
|
def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
|
|
418
|
+
"""
|
|
419
|
+
Removes specified key and return the corresponding value.
|
|
420
|
+
:param str key: The key to pop.
|
|
421
|
+
:param any default: The value to return if key is not in the dictionary
|
|
422
|
+
:returns: The value corresponding to the key.
|
|
423
|
+
:rtype: any
|
|
424
|
+
:raises KeyError: If key is not found and default is not given.
|
|
425
|
+
"""
|
|
399
426
|
if default is _UNSET:
|
|
400
427
|
return self._data.pop(key)
|
|
401
428
|
return self._data.pop(key, default)
|
|
402
429
|
|
|
403
430
|
def popitem(self) -> typing.Tuple[str, typing.Any]:
|
|
431
|
+
"""
|
|
432
|
+
Removes and returns some (key, value) pair
|
|
433
|
+
:returns: The (key, value) pair.
|
|
434
|
+
:rtype: tuple
|
|
435
|
+
:raises KeyError: if D is empty.
|
|
436
|
+
"""
|
|
404
437
|
return self._data.popitem()
|
|
405
438
|
|
|
406
439
|
def clear(self) -> None:
|
|
440
|
+
"""
|
|
441
|
+
Remove all items from D.
|
|
442
|
+
"""
|
|
407
443
|
self._data.clear()
|
|
408
444
|
|
|
409
445
|
def update(self, *args: typing.Any, **kwargs: typing.Any) -> None:
|
|
446
|
+
"""
|
|
447
|
+
Updates D from mapping/iterable E and F.
|
|
448
|
+
:param any args: Either a mapping object or an iterable of key-value pairs.
|
|
449
|
+
"""
|
|
410
450
|
self._data.update(*args, **kwargs)
|
|
411
451
|
|
|
412
452
|
@typing.overload
|
|
@@ -416,6 +456,13 @@ class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=uns
|
|
|
416
456
|
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ...
|
|
417
457
|
|
|
418
458
|
def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
|
|
459
|
+
"""
|
|
460
|
+
Same as calling D.get(k, d), and setting D[k]=d if k not found
|
|
461
|
+
:param str key: The key to look up.
|
|
462
|
+
:param any default: The value to set if key is not in the dictionary
|
|
463
|
+
:returns: D[k] if k in D, else d.
|
|
464
|
+
:rtype: any
|
|
465
|
+
"""
|
|
419
466
|
if default is _UNSET:
|
|
420
467
|
return self._data.setdefault(key)
|
|
421
468
|
return self._data.setdefault(key, default)
|
|
@@ -909,6 +956,20 @@ def _failsafe_deserialize(
|
|
|
909
956
|
return None
|
|
910
957
|
|
|
911
958
|
|
|
959
|
+
def _failsafe_deserialize_xml(
|
|
960
|
+
deserializer: typing.Any,
|
|
961
|
+
value: typing.Any,
|
|
962
|
+
) -> typing.Any:
|
|
963
|
+
try:
|
|
964
|
+
return _deserialize_xml(deserializer, value)
|
|
965
|
+
except DeserializationError:
|
|
966
|
+
_LOGGER.warning(
|
|
967
|
+
"Ran into a deserialization error. Ignoring since this is failsafe deserialization",
|
|
968
|
+
exc_info=True
|
|
969
|
+
)
|
|
970
|
+
return None
|
|
971
|
+
|
|
972
|
+
|
|
912
973
|
class _RestField:
|
|
913
974
|
def __init__(
|
|
914
975
|
self,
|
|
@@ -31,10 +31,10 @@ class {{ operation_group.class_name }}: {{ operation_group.pylint_disable() }}
|
|
|
31
31
|
{% endif %}
|
|
32
32
|
def __init__(self, *args, **kwargs){{ return_none_type_annotation }}:
|
|
33
33
|
input_args = list(args)
|
|
34
|
-
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
35
|
-
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
36
|
-
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
37
|
-
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
34
|
+
self._client: {{ 'Async' if async_mode else ''}}PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
|
|
35
|
+
self._config: {{ operation_group.client.name }}Configuration = input_args.pop(0) if input_args else kwargs.pop("config")
|
|
36
|
+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
|
|
37
|
+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
|
|
38
38
|
{% if code_model.options["multiapi"] %}
|
|
39
39
|
self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")
|
|
40
40
|
{% endif %}
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
{{ imports }}
|
|
7
7
|
{{ unset }}
|
|
8
8
|
{% if code_model.options["builders_visibility"] == "embedded" and not async_mode %}
|
|
9
|
+
{% if need_declare_serializer %}
|
|
9
10
|
{{ op_tools.declare_serializer(code_model) }}
|
|
11
|
+
{% endif %}
|
|
10
12
|
{% for operation_group in operation_groups %}
|
|
11
13
|
{% for request_builder in get_request_builders(operation_group) %}
|
|
12
14
|
|
|
@@ -47,9 +47,7 @@ from typing import (
|
|
|
47
47
|
IO,
|
|
48
48
|
Mapping,
|
|
49
49
|
Callable,
|
|
50
|
-
TypeVar,
|
|
51
50
|
MutableMapping,
|
|
52
|
-
Type,
|
|
53
51
|
List,
|
|
54
52
|
)
|
|
55
53
|
|
|
@@ -60,13 +58,13 @@ except ImportError:
|
|
|
60
58
|
import xml.etree.ElementTree as ET
|
|
61
59
|
|
|
62
60
|
import isodate # type: ignore
|
|
61
|
+
from typing_extensions import Self
|
|
63
62
|
|
|
64
63
|
from {{ code_model.core_library }}.exceptions import DeserializationError, SerializationError
|
|
65
64
|
from {{ code_model.core_library }}.serialization import NULL as CoreNull
|
|
66
65
|
|
|
67
66
|
_BOM = codecs.BOM_UTF8.decode(encoding="utf-8")
|
|
68
67
|
|
|
69
|
-
ModelType = TypeVar("ModelType", bound="Model")
|
|
70
68
|
JSON = MutableMapping[str, Any]
|
|
71
69
|
|
|
72
70
|
|
|
@@ -184,73 +182,7 @@ try:
|
|
|
184
182
|
except NameError:
|
|
185
183
|
_long_type = int
|
|
186
184
|
|
|
187
|
-
|
|
188
|
-
class UTC(datetime.tzinfo):
|
|
189
|
-
"""Time Zone info for handling UTC"""
|
|
190
|
-
|
|
191
|
-
def utcoffset(self, dt):
|
|
192
|
-
"""UTF offset for UTC is 0.
|
|
193
|
-
|
|
194
|
-
:param datetime.datetime dt: The datetime
|
|
195
|
-
:returns: The offset
|
|
196
|
-
:rtype: datetime.timedelta
|
|
197
|
-
"""
|
|
198
|
-
return datetime.timedelta(0)
|
|
199
|
-
|
|
200
|
-
def tzname(self, dt):
|
|
201
|
-
"""Timestamp representation.
|
|
202
|
-
|
|
203
|
-
:param datetime.datetime dt: The datetime
|
|
204
|
-
:returns: The timestamp representation
|
|
205
|
-
:rtype: str
|
|
206
|
-
"""
|
|
207
|
-
return "Z"
|
|
208
|
-
|
|
209
|
-
def dst(self, dt):
|
|
210
|
-
"""No daylight saving for UTC.
|
|
211
|
-
|
|
212
|
-
:param datetime.datetime dt: The datetime
|
|
213
|
-
:returns: The daylight saving time
|
|
214
|
-
:rtype: datetime.timedelta
|
|
215
|
-
"""
|
|
216
|
-
return datetime.timedelta(hours=1)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
try:
|
|
220
|
-
from datetime import timezone as _FixedOffset # type: ignore
|
|
221
|
-
except ImportError: # Python 2.7
|
|
222
|
-
|
|
223
|
-
class _FixedOffset(datetime.tzinfo): # type: ignore
|
|
224
|
-
"""Fixed offset in minutes east from UTC.
|
|
225
|
-
Copy/pasted from Python doc
|
|
226
|
-
:param datetime.timedelta offset: offset in timedelta format
|
|
227
|
-
"""
|
|
228
|
-
|
|
229
|
-
def __init__(self, offset) -> None:
|
|
230
|
-
self.__offset = offset
|
|
231
|
-
|
|
232
|
-
def utcoffset(self, dt):
|
|
233
|
-
return self.__offset
|
|
234
|
-
|
|
235
|
-
def tzname(self, dt):
|
|
236
|
-
return str(self.__offset.total_seconds() / 3600)
|
|
237
|
-
|
|
238
|
-
def __repr__(self):
|
|
239
|
-
return "<FixedOffset {}>".format(self.tzname(None))
|
|
240
|
-
|
|
241
|
-
def dst(self, dt):
|
|
242
|
-
return datetime.timedelta(0)
|
|
243
|
-
|
|
244
|
-
def __getinitargs__(self):
|
|
245
|
-
return (self.__offset,)
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
try:
|
|
249
|
-
from datetime import timezone
|
|
250
|
-
|
|
251
|
-
TZ_UTC = timezone.utc
|
|
252
|
-
except ImportError:
|
|
253
|
-
TZ_UTC = UTC() # type: ignore
|
|
185
|
+
TZ_UTC = datetime.timezone.utc
|
|
254
186
|
|
|
255
187
|
_FLATTEN = re.compile(r"(?<!\\)\.")
|
|
256
188
|
|
|
@@ -449,25 +381,25 @@ class Model:
|
|
|
449
381
|
return client_models
|
|
450
382
|
|
|
451
383
|
@classmethod
|
|
452
|
-
def deserialize(cls
|
|
384
|
+
def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self:
|
|
453
385
|
"""Parse a str using the RestAPI syntax and return a model.
|
|
454
386
|
|
|
455
387
|
:param str data: A str using RestAPI structure. JSON by default.
|
|
456
388
|
:param str content_type: JSON by default, set application/xml if XML.
|
|
457
389
|
:returns: An instance of this model
|
|
458
|
-
:raises
|
|
459
|
-
:rtype:
|
|
390
|
+
:raises DeserializationError: if something went wrong
|
|
391
|
+
:rtype: Self
|
|
460
392
|
"""
|
|
461
393
|
deserializer = Deserializer(cls._infer_class_models())
|
|
462
394
|
return deserializer(cls.__name__, data, content_type=content_type) # type: ignore
|
|
463
395
|
|
|
464
396
|
@classmethod
|
|
465
397
|
def from_dict(
|
|
466
|
-
cls
|
|
398
|
+
cls,
|
|
467
399
|
data: Any,
|
|
468
400
|
key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None,
|
|
469
401
|
content_type: Optional[str] = None,
|
|
470
|
-
) ->
|
|
402
|
+
) -> Self:
|
|
471
403
|
"""Parse a dict using given key extractor return a model.
|
|
472
404
|
|
|
473
405
|
By default consider key
|
|
@@ -479,7 +411,7 @@ class Model:
|
|
|
479
411
|
:param str content_type: JSON by default, set application/xml if XML.
|
|
480
412
|
:returns: An instance of this model
|
|
481
413
|
:raises: DeserializationError if something went wrong
|
|
482
|
-
:rtype:
|
|
414
|
+
:rtype: Self
|
|
483
415
|
"""
|
|
484
416
|
deserializer = Deserializer(cls._infer_class_models())
|
|
485
417
|
deserializer.key_extractors = ( # type: ignore
|
|
@@ -625,7 +557,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
625
557
|
:param object target_obj: The data to be serialized.
|
|
626
558
|
:param str data_type: The type to be serialized from.
|
|
627
559
|
:rtype: str, dict
|
|
628
|
-
:raises
|
|
560
|
+
:raises SerializationError: if serialization fails.
|
|
629
561
|
:returns: The serialized data.
|
|
630
562
|
"""
|
|
631
563
|
key_transformer = kwargs.get("key_transformer", self.key_transformer)
|
|
@@ -735,8 +667,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
735
667
|
:param object data: The data to be serialized.
|
|
736
668
|
:param str data_type: The type to be serialized from.
|
|
737
669
|
:rtype: dict
|
|
738
|
-
:raises
|
|
739
|
-
:raises
|
|
670
|
+
:raises SerializationError: if serialization fails.
|
|
671
|
+
:raises ValueError: if data is None
|
|
740
672
|
:returns: The serialized request body
|
|
741
673
|
"""
|
|
742
674
|
|
|
@@ -780,8 +712,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
780
712
|
:param str data_type: The type to be serialized from.
|
|
781
713
|
:rtype: str
|
|
782
714
|
:returns: The serialized URL path
|
|
783
|
-
:raises
|
|
784
|
-
:raises
|
|
715
|
+
:raises TypeError: if serialization fails.
|
|
716
|
+
:raises ValueError: if data is None
|
|
785
717
|
"""
|
|
786
718
|
try:
|
|
787
719
|
output = self.serialize_data(data, data_type, **kwargs)
|
|
@@ -804,8 +736,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
804
736
|
:param object data: The data to be serialized.
|
|
805
737
|
:param str data_type: The type to be serialized from.
|
|
806
738
|
:rtype: str, list
|
|
807
|
-
:raises
|
|
808
|
-
:raises
|
|
739
|
+
:raises TypeError: if serialization fails.
|
|
740
|
+
:raises ValueError: if data is None
|
|
809
741
|
:returns: The serialized query parameter
|
|
810
742
|
"""
|
|
811
743
|
try:
|
|
@@ -834,8 +766,8 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
834
766
|
:param object data: The data to be serialized.
|
|
835
767
|
:param str data_type: The type to be serialized from.
|
|
836
768
|
:rtype: str
|
|
837
|
-
:raises
|
|
838
|
-
:raises
|
|
769
|
+
:raises TypeError: if serialization fails.
|
|
770
|
+
:raises ValueError: if data is None
|
|
839
771
|
:returns: The serialized header
|
|
840
772
|
"""
|
|
841
773
|
try:
|
|
@@ -854,9 +786,9 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
854
786
|
|
|
855
787
|
:param object data: The data to be serialized.
|
|
856
788
|
:param str data_type: The type to be serialized from.
|
|
857
|
-
:raises
|
|
858
|
-
:raises
|
|
859
|
-
:raises
|
|
789
|
+
:raises AttributeError: if required data is None.
|
|
790
|
+
:raises ValueError: if data is None
|
|
791
|
+
:raises SerializationError: if serialization fails.
|
|
860
792
|
:returns: The serialized data.
|
|
861
793
|
:rtype: str, int, float, bool, dict, list
|
|
862
794
|
"""
|
|
@@ -1191,7 +1123,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
1191
1123
|
|
|
1192
1124
|
:param Datetime attr: Object to be serialized.
|
|
1193
1125
|
:rtype: str
|
|
1194
|
-
:raises
|
|
1126
|
+
:raises TypeError: if format invalid.
|
|
1195
1127
|
:return: serialized rfc
|
|
1196
1128
|
"""
|
|
1197
1129
|
try:
|
|
@@ -1217,7 +1149,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
1217
1149
|
|
|
1218
1150
|
:param Datetime attr: Object to be serialized.
|
|
1219
1151
|
:rtype: str
|
|
1220
|
-
:raises
|
|
1152
|
+
:raises SerializationError: if format invalid.
|
|
1221
1153
|
:return: serialized iso
|
|
1222
1154
|
"""
|
|
1223
1155
|
if isinstance(attr, str):
|
|
@@ -1250,7 +1182,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
1250
1182
|
|
|
1251
1183
|
:param Datetime attr: Object to be serialized.
|
|
1252
1184
|
:rtype: int
|
|
1253
|
-
:raises
|
|
1185
|
+
:raises SerializationError: if format invalid
|
|
1254
1186
|
:return: serialied unix
|
|
1255
1187
|
"""
|
|
1256
1188
|
if isinstance(attr, int):
|
|
@@ -1487,7 +1419,7 @@ class Deserializer:
|
|
|
1487
1419
|
:param str target_obj: Target data type to deserialize to.
|
|
1488
1420
|
:param requests.Response response_data: REST response object.
|
|
1489
1421
|
:param str content_type: Swagger "produces" if available.
|
|
1490
|
-
:raises
|
|
1422
|
+
:raises DeserializationError: if deserialization fails.
|
|
1491
1423
|
:return: Deserialized object.
|
|
1492
1424
|
:rtype: object
|
|
1493
1425
|
"""
|
|
@@ -1501,7 +1433,7 @@ class Deserializer:
|
|
|
1501
1433
|
|
|
1502
1434
|
:param str target_obj: Target data type to deserialize to.
|
|
1503
1435
|
:param object data: Object to deserialize.
|
|
1504
|
-
:raises
|
|
1436
|
+
:raises DeserializationError: if deserialization fails.
|
|
1505
1437
|
:return: Deserialized object.
|
|
1506
1438
|
:rtype: object
|
|
1507
1439
|
"""
|
|
@@ -1716,7 +1648,7 @@ class Deserializer:
|
|
|
1716
1648
|
|
|
1717
1649
|
:param str data: The response string to be deserialized.
|
|
1718
1650
|
:param str data_type: The type to deserialize to.
|
|
1719
|
-
:raises
|
|
1651
|
+
:raises DeserializationError: if deserialization fails.
|
|
1720
1652
|
:return: Deserialized object.
|
|
1721
1653
|
:rtype: object
|
|
1722
1654
|
"""
|
|
@@ -1798,7 +1730,7 @@ class Deserializer:
|
|
|
1798
1730
|
:param dict attr: Dictionary to be deserialized.
|
|
1799
1731
|
:return: Deserialized object.
|
|
1800
1732
|
:rtype: dict
|
|
1801
|
-
:raises
|
|
1733
|
+
:raises TypeError: if non-builtin datatype encountered.
|
|
1802
1734
|
"""
|
|
1803
1735
|
if attr is None:
|
|
1804
1736
|
return None
|
|
@@ -1844,7 +1776,7 @@ class Deserializer:
|
|
|
1844
1776
|
:param str data_type: deserialization data type.
|
|
1845
1777
|
:return: Deserialized basic type.
|
|
1846
1778
|
:rtype: str, int, float or bool
|
|
1847
|
-
:raises
|
|
1779
|
+
:raises TypeError: if string format is not valid.
|
|
1848
1780
|
"""
|
|
1849
1781
|
# If we're here, data is supposed to be a basic type.
|
|
1850
1782
|
# If it's still an XML node, take the text
|
|
@@ -1935,7 +1867,7 @@ class Deserializer:
|
|
|
1935
1867
|
:param str attr: response string to be deserialized.
|
|
1936
1868
|
:return: Deserialized bytearray
|
|
1937
1869
|
:rtype: bytearray
|
|
1938
|
-
:raises
|
|
1870
|
+
:raises TypeError: if string format invalid.
|
|
1939
1871
|
"""
|
|
1940
1872
|
if isinstance(attr, ET.Element):
|
|
1941
1873
|
attr = attr.text
|
|
@@ -1948,7 +1880,7 @@ class Deserializer:
|
|
|
1948
1880
|
:param str attr: response string to be deserialized.
|
|
1949
1881
|
:return: Deserialized base64 string
|
|
1950
1882
|
:rtype: bytearray
|
|
1951
|
-
:raises
|
|
1883
|
+
:raises TypeError: if string format invalid.
|
|
1952
1884
|
"""
|
|
1953
1885
|
if isinstance(attr, ET.Element):
|
|
1954
1886
|
attr = attr.text
|
|
@@ -1963,7 +1895,7 @@ class Deserializer:
|
|
|
1963
1895
|
|
|
1964
1896
|
:param str attr: response string to be deserialized.
|
|
1965
1897
|
:return: Deserialized decimal
|
|
1966
|
-
:raises
|
|
1898
|
+
:raises DeserializationError: if string format invalid.
|
|
1967
1899
|
:rtype: decimal
|
|
1968
1900
|
"""
|
|
1969
1901
|
if isinstance(attr, ET.Element):
|
|
@@ -1981,7 +1913,7 @@ class Deserializer:
|
|
|
1981
1913
|
:param str attr: response string to be deserialized.
|
|
1982
1914
|
:return: Deserialized int
|
|
1983
1915
|
:rtype: long or int
|
|
1984
|
-
:raises
|
|
1916
|
+
:raises ValueError: if string format invalid.
|
|
1985
1917
|
"""
|
|
1986
1918
|
if isinstance(attr, ET.Element):
|
|
1987
1919
|
attr = attr.text
|
|
@@ -1994,7 +1926,7 @@ class Deserializer:
|
|
|
1994
1926
|
:param str attr: response string to be deserialized.
|
|
1995
1927
|
:return: Deserialized duration
|
|
1996
1928
|
:rtype: TimeDelta
|
|
1997
|
-
:raises
|
|
1929
|
+
:raises DeserializationError: if string format invalid.
|
|
1998
1930
|
"""
|
|
1999
1931
|
if isinstance(attr, ET.Element):
|
|
2000
1932
|
attr = attr.text
|
|
@@ -2012,7 +1944,7 @@ class Deserializer:
|
|
|
2012
1944
|
:param str attr: response string to be deserialized.
|
|
2013
1945
|
:return: Deserialized date
|
|
2014
1946
|
:rtype: Date
|
|
2015
|
-
:raises
|
|
1947
|
+
:raises DeserializationError: if string format invalid.
|
|
2016
1948
|
"""
|
|
2017
1949
|
if isinstance(attr, ET.Element):
|
|
2018
1950
|
attr = attr.text
|
|
@@ -2028,7 +1960,7 @@ class Deserializer:
|
|
|
2028
1960
|
:param str attr: response string to be deserialized.
|
|
2029
1961
|
:return: Deserialized time
|
|
2030
1962
|
:rtype: datetime.time
|
|
2031
|
-
:raises
|
|
1963
|
+
:raises DeserializationError: if string format invalid.
|
|
2032
1964
|
"""
|
|
2033
1965
|
if isinstance(attr, ET.Element):
|
|
2034
1966
|
attr = attr.text
|
|
@@ -2043,14 +1975,14 @@ class Deserializer:
|
|
|
2043
1975
|
:param str attr: response string to be deserialized.
|
|
2044
1976
|
:return: Deserialized RFC datetime
|
|
2045
1977
|
:rtype: Datetime
|
|
2046
|
-
:raises
|
|
1978
|
+
:raises DeserializationError: if string format invalid.
|
|
2047
1979
|
"""
|
|
2048
1980
|
if isinstance(attr, ET.Element):
|
|
2049
1981
|
attr = attr.text
|
|
2050
1982
|
try:
|
|
2051
1983
|
parsed_date = email.utils.parsedate_tz(attr) # type: ignore
|
|
2052
1984
|
date_obj = datetime.datetime(
|
|
2053
|
-
*parsed_date[:6], tzinfo=
|
|
1985
|
+
*parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60))
|
|
2054
1986
|
)
|
|
2055
1987
|
if not date_obj.tzinfo:
|
|
2056
1988
|
date_obj = date_obj.astimezone(tz=TZ_UTC)
|
|
@@ -2066,7 +1998,7 @@ class Deserializer:
|
|
|
2066
1998
|
:param str attr: response string to be deserialized.
|
|
2067
1999
|
:return: Deserialized ISO datetime
|
|
2068
2000
|
:rtype: Datetime
|
|
2069
|
-
:raises
|
|
2001
|
+
:raises DeserializationError: if string format invalid.
|
|
2070
2002
|
"""
|
|
2071
2003
|
if isinstance(attr, ET.Element):
|
|
2072
2004
|
attr = attr.text
|
|
@@ -2104,7 +2036,7 @@ class Deserializer:
|
|
|
2104
2036
|
:param int attr: Object to be serialized.
|
|
2105
2037
|
:return: Deserialized datetime
|
|
2106
2038
|
:rtype: Datetime
|
|
2107
|
-
:raises
|
|
2039
|
+
:raises DeserializationError: if format invalid
|
|
2108
2040
|
"""
|
|
2109
2041
|
if isinstance(attr, ET.Element):
|
|
2110
2042
|
attr = int(attr.text) # type: ignore
|
|
@@ -92,9 +92,9 @@ def add_overloads_for_body_param(yaml_data: Dict[str, Any]) -> None:
|
|
|
92
92
|
for body_type in body_parameter["type"]["types"]:
|
|
93
93
|
if any(o for o in yaml_data["overloads"] if id(o["bodyParameter"]["type"]) == id(body_type)):
|
|
94
94
|
continue
|
|
95
|
-
yaml_data["overloads"].append(add_overload(yaml_data, body_type))
|
|
96
95
|
if body_type.get("type") == "model" and body_type.get("base") == "json":
|
|
97
96
|
yaml_data["overloads"].append(add_overload(yaml_data, body_type, for_flatten_params=True))
|
|
97
|
+
yaml_data["overloads"].append(add_overload(yaml_data, body_type))
|
|
98
98
|
content_type_param = next(p for p in yaml_data["parameters"] if p["wireName"].lower() == "content-type")
|
|
99
99
|
content_type_param["inOverload"] = False
|
|
100
100
|
content_type_param["inOverridden"] = True
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "6.28.
|
|
3
|
+
"version": "6.28.2",
|
|
4
4
|
"description": "The Python extension for generators in AutoRest.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@typespec/http-client-python": "~0.6.
|
|
22
|
+
"@typespec/http-client-python": "~0.6.9",
|
|
23
23
|
"@autorest/system-requirements": "~1.0.2",
|
|
24
24
|
"fs-extra": "~11.2.0",
|
|
25
25
|
"tsx": "~4.19.1"
|
|
Binary file
|
package/scripts/eng/mypy.ini
CHANGED
package/scripts/mypy.ini
CHANGED
package/scripts/prepare.py
CHANGED
|
@@ -22,9 +22,9 @@ _ROOT_DIR = Path(__file__).parent.parent
|
|
|
22
22
|
|
|
23
23
|
def main():
|
|
24
24
|
venv_path = _ROOT_DIR / "venv"
|
|
25
|
-
|
|
25
|
+
venv_preexists = venv_path.exists()
|
|
26
26
|
|
|
27
|
-
assert
|
|
27
|
+
assert venv_preexists # Otherwise install was not done
|
|
28
28
|
|
|
29
29
|
env_builder = venv.EnvBuilder(with_pip=True)
|
|
30
30
|
venv_context = env_builder.ensure_directories(venv_path)
|
package/scripts/start.py
CHANGED
|
@@ -20,9 +20,9 @@ _ROOT_DIR = Path(__file__).parent.parent
|
|
|
20
20
|
|
|
21
21
|
def main():
|
|
22
22
|
venv_path = _ROOT_DIR / "venv"
|
|
23
|
-
|
|
23
|
+
venv_preexists = venv_path.exists()
|
|
24
24
|
|
|
25
|
-
assert
|
|
25
|
+
assert venv_preexists # Otherwise install was not done
|
|
26
26
|
|
|
27
27
|
if sys.version_info < (3, 9, 0):
|
|
28
28
|
env_builder = venv.EnvBuilder(with_pip=True)
|
package/scripts/venvtools.py
CHANGED
|
@@ -49,9 +49,9 @@ def create(
|
|
|
49
49
|
|
|
50
50
|
@contextmanager
|
|
51
51
|
def create_venv_with_package(packages):
|
|
52
|
-
"""Create a venv with these packages in a temp dir and
|
|
52
|
+
"""Create a venv with these packages in a temp dir and yield the env.
|
|
53
53
|
|
|
54
|
-
packages should be an iterable of pip version
|
|
54
|
+
packages should be an iterable of pip version instructions (e.g. package~=1.2.3)
|
|
55
55
|
"""
|
|
56
56
|
with tempfile.TemporaryDirectory() as tempdir:
|
|
57
57
|
myenv = create(tempdir, with_pip=True, upgrade_deps=True)
|