@autorest/python 6.49.2 → 6.50.0
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/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +6 -2
- package/generator/build/lib/pygen/preprocess/__init__.py +9 -21
- package/generator/build/lib/pygen/preprocess/python_mappings.py +0 -2
- package/generator/component-detection-pip-report.json +5 -6
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +6 -2
- package/generator/pygen/preprocess/__init__.py +9 -21
- package/generator/pygen/preprocess/python_mappings.py +0 -2
- package/package.json +2 -2
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
|
@@ -652,6 +652,9 @@ class Model(_MyMutableMapping):
|
|
|
652
652
|
if len(items) > 0:
|
|
653
653
|
existed_attr_keys.append(xml_name)
|
|
654
654
|
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
|
|
655
|
+
elif not rf._is_optional:
|
|
656
|
+
existed_attr_keys.append(xml_name)
|
|
657
|
+
dict_to_pass[rf._rest_name] = []
|
|
655
658
|
continue
|
|
656
659
|
|
|
657
660
|
# text element is primitive type
|
|
@@ -930,6 +933,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
|
|
|
930
933
|
# is it optional?
|
|
931
934
|
try:
|
|
932
935
|
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
|
|
936
|
+
if rf:
|
|
937
|
+
rf._is_optional = True
|
|
933
938
|
if len(annotation.__args__) <= 2: # pyright: ignore
|
|
934
939
|
if_obj_deserializer = _get_deserialize_callable_from_annotation(
|
|
935
940
|
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
|
|
@@ -1090,9 +1095,7 @@ def _failsafe_deserialize_xml(
|
|
|
1090
1095
|
return None
|
|
1091
1096
|
|
|
1092
1097
|
|
|
1093
|
-
{% if code_model.has_padded_model_property %}
|
|
1094
1098
|
# pylint: disable=too-many-instance-attributes
|
|
1095
|
-
{% endif %}
|
|
1096
1099
|
class _RestField:
|
|
1097
1100
|
def __init__(
|
|
1098
1101
|
self,
|
|
@@ -1115,6 +1118,7 @@ class _RestField:
|
|
|
1115
1118
|
self._is_discriminator = is_discriminator
|
|
1116
1119
|
self._visibility = visibility
|
|
1117
1120
|
self._is_model = False
|
|
1121
|
+
self._is_optional = False
|
|
1118
1122
|
self._default = default
|
|
1119
1123
|
self._format = format
|
|
1120
1124
|
self._is_multipart_file_input = is_multipart_file_input
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
"""The preprocessing autorest plugin."""
|
|
7
|
+
|
|
7
8
|
import copy
|
|
8
9
|
from typing import Callable, Any, Optional
|
|
9
10
|
|
|
@@ -21,7 +22,6 @@ from ..utils import (
|
|
|
21
22
|
get_body_type_for_description,
|
|
22
23
|
JSON_REGEXP,
|
|
23
24
|
KNOWN_TYPES,
|
|
24
|
-
update_enum_value,
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
|
|
@@ -267,30 +267,18 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
267
267
|
add_redefined_builtin_info(property["clientName"], property)
|
|
268
268
|
if type.get("name"):
|
|
269
269
|
pad_type = PadType.MODEL if type["type"] == "model" else PadType.ENUM_CLASS
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
if type["type"] != "enumvalue":
|
|
271
|
+
name = self.pad_reserved_words(type["name"], pad_type, type)
|
|
272
|
+
type["name"] = name[0].upper() + name[1:]
|
|
272
273
|
type["description"] = update_description(type.get("description", ""), type["name"])
|
|
273
274
|
type["snakeCaseName"] = to_snake_case(type["name"])
|
|
274
275
|
if type.get("values"):
|
|
275
|
-
# we're enums
|
|
276
|
-
values_to_add = []
|
|
276
|
+
# we're enums - enum values are UPPER_CASE so no padding needed for reserved words
|
|
277
277
|
for value in type["values"]:
|
|
278
|
-
|
|
279
|
-
if
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
value["name"] = padded_name
|
|
283
|
-
else:
|
|
284
|
-
if value["name"] != padded_name:
|
|
285
|
-
values_to_add.append(
|
|
286
|
-
update_enum_value(
|
|
287
|
-
name=padded_name,
|
|
288
|
-
value=value["value"],
|
|
289
|
-
description=value["description"],
|
|
290
|
-
enum_type=value["enumType"],
|
|
291
|
-
)
|
|
292
|
-
)
|
|
293
|
-
type["values"].extend(values_to_add)
|
|
278
|
+
upper_name = value["name"].upper()
|
|
279
|
+
if upper_name[0] in "0123456789":
|
|
280
|
+
upper_name = "ENUM_" + upper_name
|
|
281
|
+
value["name"] = upper_name
|
|
294
282
|
|
|
295
283
|
# add type for reference
|
|
296
284
|
for v in HEADERS_CONVERT_IN_METHOD.values():
|
|
@@ -56,7 +56,6 @@ class PadType(str, Enum):
|
|
|
56
56
|
ENUM_CLASS = "Enum"
|
|
57
57
|
METHOD = "_method"
|
|
58
58
|
PARAMETER = "_parameter"
|
|
59
|
-
ENUM_VALUE = "_enum"
|
|
60
59
|
PROPERTY = "_property"
|
|
61
60
|
OPERATION_GROUP = "Operations"
|
|
62
61
|
|
|
@@ -183,7 +182,6 @@ RESERVED_WORDS = {
|
|
|
183
182
|
PadType.MODEL: ["enum", *_always_reserved],
|
|
184
183
|
PadType.PROPERTY: ["self", *_always_reserved],
|
|
185
184
|
PadType.ENUM_CLASS: ["enum", *_always_reserved],
|
|
186
|
-
PadType.ENUM_VALUE: ["mro", *_always_reserved],
|
|
187
185
|
PadType.OPERATION_GROUP: [*_always_reserved],
|
|
188
186
|
}
|
|
189
187
|
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"install": [
|
|
5
5
|
{
|
|
6
6
|
"download_info": {
|
|
7
|
-
"url": "https://files.pythonhosted.org/packages/
|
|
7
|
+
"url": "https://files.pythonhosted.org/packages/9d/76/f789f7a86709c6b087c5a2f52f911838cad707cc613162401badc665acfe/setuptools-82.0.1-py3-none-any.whl",
|
|
8
8
|
"archive_info": {
|
|
9
|
-
"hash": "sha256=
|
|
9
|
+
"hash": "sha256=a59e362652f08dcd477c78bb6e7bd9d80a7995bc73ce773050228a348ce2e5bb",
|
|
10
10
|
"hashes": {
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "a59e362652f08dcd477c78bb6e7bd9d80a7995bc73ce773050228a348ce2e5bb"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"metadata": {
|
|
19
19
|
"metadata_version": "2.4",
|
|
20
20
|
"name": "setuptools",
|
|
21
|
-
"version": "82.0.
|
|
21
|
+
"version": "82.0.1",
|
|
22
22
|
"dynamic": [
|
|
23
23
|
"license-file"
|
|
24
24
|
],
|
|
25
|
-
"summary": "
|
|
25
|
+
"summary": "Most extensible Python build backend with support for C/C++ extension modules",
|
|
26
26
|
"description": ".. |pypi-version| image:: https://img.shields.io/pypi/v/setuptools.svg\n :target: https://pypi.org/project/setuptools\n\n.. |py-version| image:: https://img.shields.io/pypi/pyversions/setuptools.svg\n\n.. |test-badge| image:: https://github.com/pypa/setuptools/actions/workflows/main.yml/badge.svg\n :target: https://github.com/pypa/setuptools/actions?query=workflow%3A%22tests%22\n :alt: tests\n\n.. |ruff-badge| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json\n :target: https://github.com/astral-sh/ruff\n :alt: Ruff\n\n.. |docs-badge| image:: https://img.shields.io/readthedocs/setuptools/latest.svg\n :target: https://setuptools.pypa.io\n\n.. |skeleton-badge| image:: https://img.shields.io/badge/skeleton-2025-informational\n :target: https://blog.jaraco.com/skeleton\n\n.. |codecov-badge| image:: https://img.shields.io/codecov/c/github/pypa/setuptools/master.svg?logo=codecov&logoColor=white\n :target: https://codecov.io/gh/pypa/setuptools\n\n.. |tidelift-badge| image:: https://tidelift.com/badges/github/pypa/setuptools?style=flat\n :target: https://tidelift.com/subscription/pkg/pypi-setuptools?utm_source=pypi-setuptools&utm_medium=readme\n\n.. |discord-badge| image:: https://img.shields.io/discord/803025117553754132\n :target: https://discord.com/channels/803025117553754132/815945031150993468\n :alt: Discord\n\n|pypi-version| |py-version| |test-badge| |ruff-badge| |docs-badge| |skeleton-badge| |codecov-badge| |discord-badge|\n\nSee the `Quickstart <https://setuptools.pypa.io/en/latest/userguide/quickstart.html>`_\nand the `User's Guide <https://setuptools.pypa.io/en/latest/userguide/>`_ for\ninstructions on how to use Setuptools.\n\nQuestions and comments should be directed to `GitHub Discussions\n<https://github.com/pypa/setuptools/discussions>`_.\nBug reports and especially tested patches may be\nsubmitted directly to the `bug tracker\n<https://github.com/pypa/setuptools/issues>`_.\n\n\nCode of Conduct\n===============\n\nEveryone interacting in the setuptools project's codebases, issue trackers,\nchat rooms, and fora is expected to follow the\n`PSF Code of Conduct <https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md>`_.\n\n\nFor Enterprise\n==============\n\nAvailable as part of the Tidelift Subscription.\n\nSetuptools and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.\n\n`Learn more <https://tidelift.com/subscription/pkg/pypi-setuptools?utm_source=pypi-setuptools&utm_medium=referral&utm_campaign=github>`_.\n",
|
|
27
27
|
"description_content_type": "text/x-rst",
|
|
28
28
|
"keywords": [
|
|
@@ -88,7 +88,6 @@
|
|
|
88
88
|
"importlib_metadata>=6; python_version < \"3.10\" and extra == \"core\"",
|
|
89
89
|
"tomli>=2.0.1; python_version < \"3.11\" and extra == \"core\"",
|
|
90
90
|
"wheel>=0.43.0; extra == \"core\"",
|
|
91
|
-
"platformdirs>=4.2.2; extra == \"core\"",
|
|
92
91
|
"jaraco.functools>=4; extra == \"core\"",
|
|
93
92
|
"more_itertools; extra == \"core\"",
|
|
94
93
|
"pytest-checkdocs>=2.4; extra == \"check\"",
|
|
Binary file
|
|
@@ -652,6 +652,9 @@ class Model(_MyMutableMapping):
|
|
|
652
652
|
if len(items) > 0:
|
|
653
653
|
existed_attr_keys.append(xml_name)
|
|
654
654
|
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
|
|
655
|
+
elif not rf._is_optional:
|
|
656
|
+
existed_attr_keys.append(xml_name)
|
|
657
|
+
dict_to_pass[rf._rest_name] = []
|
|
655
658
|
continue
|
|
656
659
|
|
|
657
660
|
# text element is primitive type
|
|
@@ -930,6 +933,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
|
|
|
930
933
|
# is it optional?
|
|
931
934
|
try:
|
|
932
935
|
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
|
|
936
|
+
if rf:
|
|
937
|
+
rf._is_optional = True
|
|
933
938
|
if len(annotation.__args__) <= 2: # pyright: ignore
|
|
934
939
|
if_obj_deserializer = _get_deserialize_callable_from_annotation(
|
|
935
940
|
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
|
|
@@ -1090,9 +1095,7 @@ def _failsafe_deserialize_xml(
|
|
|
1090
1095
|
return None
|
|
1091
1096
|
|
|
1092
1097
|
|
|
1093
|
-
{% if code_model.has_padded_model_property %}
|
|
1094
1098
|
# pylint: disable=too-many-instance-attributes
|
|
1095
|
-
{% endif %}
|
|
1096
1099
|
class _RestField:
|
|
1097
1100
|
def __init__(
|
|
1098
1101
|
self,
|
|
@@ -1115,6 +1118,7 @@ class _RestField:
|
|
|
1115
1118
|
self._is_discriminator = is_discriminator
|
|
1116
1119
|
self._visibility = visibility
|
|
1117
1120
|
self._is_model = False
|
|
1121
|
+
self._is_optional = False
|
|
1118
1122
|
self._default = default
|
|
1119
1123
|
self._format = format
|
|
1120
1124
|
self._is_multipart_file_input = is_multipart_file_input
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
"""The preprocessing autorest plugin."""
|
|
7
|
+
|
|
7
8
|
import copy
|
|
8
9
|
from typing import Callable, Any, Optional
|
|
9
10
|
|
|
@@ -21,7 +22,6 @@ from ..utils import (
|
|
|
21
22
|
get_body_type_for_description,
|
|
22
23
|
JSON_REGEXP,
|
|
23
24
|
KNOWN_TYPES,
|
|
24
|
-
update_enum_value,
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
|
|
@@ -267,30 +267,18 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
267
267
|
add_redefined_builtin_info(property["clientName"], property)
|
|
268
268
|
if type.get("name"):
|
|
269
269
|
pad_type = PadType.MODEL if type["type"] == "model" else PadType.ENUM_CLASS
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
if type["type"] != "enumvalue":
|
|
271
|
+
name = self.pad_reserved_words(type["name"], pad_type, type)
|
|
272
|
+
type["name"] = name[0].upper() + name[1:]
|
|
272
273
|
type["description"] = update_description(type.get("description", ""), type["name"])
|
|
273
274
|
type["snakeCaseName"] = to_snake_case(type["name"])
|
|
274
275
|
if type.get("values"):
|
|
275
|
-
# we're enums
|
|
276
|
-
values_to_add = []
|
|
276
|
+
# we're enums - enum values are UPPER_CASE so no padding needed for reserved words
|
|
277
277
|
for value in type["values"]:
|
|
278
|
-
|
|
279
|
-
if
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
value["name"] = padded_name
|
|
283
|
-
else:
|
|
284
|
-
if value["name"] != padded_name:
|
|
285
|
-
values_to_add.append(
|
|
286
|
-
update_enum_value(
|
|
287
|
-
name=padded_name,
|
|
288
|
-
value=value["value"],
|
|
289
|
-
description=value["description"],
|
|
290
|
-
enum_type=value["enumType"],
|
|
291
|
-
)
|
|
292
|
-
)
|
|
293
|
-
type["values"].extend(values_to_add)
|
|
278
|
+
upper_name = value["name"].upper()
|
|
279
|
+
if upper_name[0] in "0123456789":
|
|
280
|
+
upper_name = "ENUM_" + upper_name
|
|
281
|
+
value["name"] = upper_name
|
|
294
282
|
|
|
295
283
|
# add type for reference
|
|
296
284
|
for v in HEADERS_CONVERT_IN_METHOD.values():
|
|
@@ -56,7 +56,6 @@ class PadType(str, Enum):
|
|
|
56
56
|
ENUM_CLASS = "Enum"
|
|
57
57
|
METHOD = "_method"
|
|
58
58
|
PARAMETER = "_parameter"
|
|
59
|
-
ENUM_VALUE = "_enum"
|
|
60
59
|
PROPERTY = "_property"
|
|
61
60
|
OPERATION_GROUP = "Operations"
|
|
62
61
|
|
|
@@ -183,7 +182,6 @@ RESERVED_WORDS = {
|
|
|
183
182
|
PadType.MODEL: ["enum", *_always_reserved],
|
|
184
183
|
PadType.PROPERTY: ["self", *_always_reserved],
|
|
185
184
|
PadType.ENUM_CLASS: ["enum", *_always_reserved],
|
|
186
|
-
PadType.ENUM_VALUE: ["mro", *_always_reserved],
|
|
187
185
|
PadType.OPERATION_GROUP: [*_always_reserved],
|
|
188
186
|
}
|
|
189
187
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.50.0",
|
|
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.
|
|
22
|
+
"@typespec/http-client-python": "~0.28.0",
|
|
23
23
|
"@autorest/system-requirements": "~1.0.2",
|
|
24
24
|
"fs-extra": "~11.2.0",
|
|
25
25
|
"tsx": "^4.21.0"
|
|
Binary file
|