@autorest/python 6.38.0 → 6.38.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/generator/build/lib/pygen/__init__.py +10 -2
- package/generator/build/lib/pygen/codegen/serializers/__init__.py +16 -7
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +4 -8
- package/generator/build/lib/pygen/codegen/serializers/general_serializer.py +3 -1
- package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +5 -4
- package/generator/build/lib/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +2 -1
- package/generator/build/lib/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2 +9 -5
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/__init__.py +10 -2
- package/generator/pygen/codegen/serializers/__init__.py +16 -7
- package/generator/pygen/codegen/serializers/builder_serializer.py +4 -8
- package/generator/pygen/codegen/serializers/general_serializer.py +3 -1
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +5 -4
- package/generator/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +2 -1
- package/generator/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2 +9 -5
- package/package.json +2 -2
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
|
@@ -46,7 +46,7 @@ class OptionsDict(MutableMapping):
|
|
|
46
46
|
self._data = options.copy() if options else {}
|
|
47
47
|
self._validate_combinations()
|
|
48
48
|
|
|
49
|
-
def __getitem__(self, key: str) -> Any:
|
|
49
|
+
def __getitem__(self, key: str) -> Any: # pylint: disable=too-many-return-statements
|
|
50
50
|
if key == "head-as-boolean" and self.get("azure-arm"):
|
|
51
51
|
# override to always true if azure-arm is set
|
|
52
52
|
return True
|
|
@@ -69,6 +69,9 @@ class OptionsDict(MutableMapping):
|
|
|
69
69
|
data = data[2:]
|
|
70
70
|
elif data.startswith("."):
|
|
71
71
|
data = data[1:]
|
|
72
|
+
# Remove trailing slashes
|
|
73
|
+
if data.endswith("/") or data.endswith("\\"):
|
|
74
|
+
data = data[:-1]
|
|
72
75
|
return data
|
|
73
76
|
return self._get_default(key)
|
|
74
77
|
|
|
@@ -106,7 +109,12 @@ class OptionsDict(MutableMapping):
|
|
|
106
109
|
if key == "combine-operation-files":
|
|
107
110
|
return self.get("version-tolerant")
|
|
108
111
|
if key == "package-pprint-name":
|
|
109
|
-
|
|
112
|
+
package_names = self.get("package-name", "").split("-")
|
|
113
|
+
return (
|
|
114
|
+
(package_names[-1].capitalize() + " Management")
|
|
115
|
+
if self.get("azure-arm")
|
|
116
|
+
else " ".join([i.capitalize() for i in package_names])
|
|
117
|
+
)
|
|
110
118
|
if key == "builders-visibility":
|
|
111
119
|
# Default to public if low-level client is not set, otherwise embedded
|
|
112
120
|
return "embedded" if not self.get("low-level-client") else "public"
|
|
@@ -149,9 +149,12 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
149
149
|
self._serialize_and_write_package_files()
|
|
150
150
|
|
|
151
151
|
# write apiview-properties.json
|
|
152
|
-
if
|
|
152
|
+
if (
|
|
153
|
+
self.code_model.options.get("emit-cross-language-definition-file")
|
|
154
|
+
and not self.code_model.options["multiapi"]
|
|
155
|
+
):
|
|
153
156
|
self.write_file(
|
|
154
|
-
|
|
157
|
+
self._root_of_sdk / Path("apiview-properties.json"),
|
|
155
158
|
general_serializer.serialize_cross_language_definition_file(),
|
|
156
159
|
)
|
|
157
160
|
|
|
@@ -165,7 +168,7 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
165
168
|
# add _metadata.json
|
|
166
169
|
if self.code_model.metadata:
|
|
167
170
|
self.write_file(
|
|
168
|
-
|
|
171
|
+
self._root_of_sdk / "_metadata.json",
|
|
169
172
|
json.dumps(self.code_model.metadata, indent=2),
|
|
170
173
|
)
|
|
171
174
|
elif client_namespace_type.clients:
|
|
@@ -216,11 +219,17 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
216
219
|
general_serializer.serialize_pkgutil_init_file(),
|
|
217
220
|
)
|
|
218
221
|
|
|
219
|
-
|
|
222
|
+
# path where README.md is
|
|
223
|
+
@property
|
|
224
|
+
def _root_of_sdk(self) -> Path:
|
|
220
225
|
root_of_sdk = Path(".")
|
|
221
226
|
if self.code_model.options["no-namespace-folders"]:
|
|
222
227
|
compensation = Path("../" * (self.code_model.namespace.count(".") + 1))
|
|
223
228
|
root_of_sdk = root_of_sdk / compensation
|
|
229
|
+
return root_of_sdk
|
|
230
|
+
|
|
231
|
+
def _serialize_and_write_package_files(self) -> None:
|
|
232
|
+
root_of_sdk = self._root_of_sdk
|
|
224
233
|
if self.code_model.options["package-mode"] in VALID_PACKAGE_MODE:
|
|
225
234
|
env = Environment(
|
|
226
235
|
loader=PackageLoader("pygen.codegen", "templates/packaging_templates"),
|
|
@@ -520,14 +529,14 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
520
529
|
namespace_config = get_namespace_config(self.code_model.namespace, self.code_model.options["multiapi"])
|
|
521
530
|
num_of_namespace = namespace_config.count(".") + 1
|
|
522
531
|
num_of_package_namespace = (
|
|
523
|
-
get_namespace_from_package_name(self.code_model.options.get("
|
|
532
|
+
get_namespace_from_package_name(self.code_model.options.get("package-name", "")).count(".") + 1
|
|
524
533
|
)
|
|
525
534
|
if num_of_namespace > num_of_package_namespace:
|
|
526
535
|
return Path("/".join(namespace_config.split(".")[num_of_package_namespace:]))
|
|
527
536
|
return Path("")
|
|
528
537
|
|
|
529
538
|
def _serialize_and_write_sample(self, env: Environment):
|
|
530
|
-
out_path =
|
|
539
|
+
out_path = self._root_of_sdk / "generated_samples"
|
|
531
540
|
for client in self.code_model.clients:
|
|
532
541
|
for op_group in client.operation_groups:
|
|
533
542
|
for operation in op_group.operations:
|
|
@@ -561,7 +570,7 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
561
570
|
|
|
562
571
|
def _serialize_and_write_test(self, env: Environment):
|
|
563
572
|
self.code_model.for_test = True
|
|
564
|
-
out_path =
|
|
573
|
+
out_path = self._root_of_sdk / "generated_tests"
|
|
565
574
|
general_serializer = TestGeneralSerializer(code_model=self.code_model, env=env)
|
|
566
575
|
self.write_file(out_path / "conftest.py", general_serializer.serialize_conftest())
|
|
567
576
|
if not self.code_model.options["azure-arm"]:
|
|
@@ -1032,7 +1032,7 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1032
1032
|
is_operation_file=True, skip_quote=True, serialize_namespace=self.serialize_namespace
|
|
1033
1033
|
)
|
|
1034
1034
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1035
|
-
retval.append(f" error = _failsafe_deserialize({type_annotation}, response
|
|
1035
|
+
retval.append(f" error = _failsafe_deserialize({type_annotation}, response)")
|
|
1036
1036
|
else:
|
|
1037
1037
|
retval.append(
|
|
1038
1038
|
f" error = self._deserialize.failsafe_deserialize({type_annotation}, "
|
|
@@ -1067,11 +1067,9 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1067
1067
|
)
|
|
1068
1068
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1069
1069
|
if xml_serializable(str(e.default_content_type)):
|
|
1070
|
-
retval.append(
|
|
1071
|
-
f" error = _failsafe_deserialize_xml({type_annotation}, response.text())"
|
|
1072
|
-
)
|
|
1070
|
+
retval.append(f" error = _failsafe_deserialize_xml({type_annotation}, response)")
|
|
1073
1071
|
else:
|
|
1074
|
-
retval.append(f" error = _failsafe_deserialize({type_annotation},
|
|
1072
|
+
retval.append(f" error = _failsafe_deserialize({type_annotation}, response)")
|
|
1075
1073
|
else:
|
|
1076
1074
|
retval.append(
|
|
1077
1075
|
f" error = self._deserialize.failsafe_deserialize({type_annotation}, "
|
|
@@ -1086,9 +1084,7 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1086
1084
|
if builder.non_default_errors:
|
|
1087
1085
|
retval.append(" else:")
|
|
1088
1086
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1089
|
-
retval.append(
|
|
1090
|
-
f"{indent}error = _failsafe_deserialize({default_error_deserialization}, response.json())"
|
|
1091
|
-
)
|
|
1087
|
+
retval.append(f"{indent}error = _failsafe_deserialize({default_error_deserialization}, response)")
|
|
1092
1088
|
else:
|
|
1093
1089
|
retval.append(
|
|
1094
1090
|
f"{indent}error = self._deserialize.failsafe_deserialize({default_error_deserialization}, "
|
|
@@ -70,9 +70,11 @@ class GeneralSerializer(BaseSerializer):
|
|
|
70
70
|
# If parsing the pyproject.toml fails, we assume the it does not exist or is incorrectly formatted.
|
|
71
71
|
return result
|
|
72
72
|
|
|
73
|
-
# Keep azure-sdk-build configuration
|
|
73
|
+
# Keep "azure-sdk-build" and "packaging" configuration
|
|
74
74
|
if "tool" in loaded_pyproject_toml and "azure-sdk-build" in loaded_pyproject_toml["tool"]:
|
|
75
75
|
result["KEEP_FIELDS"]["tool.azure-sdk-build"] = loaded_pyproject_toml["tool"]["azure-sdk-build"]
|
|
76
|
+
if "packaging" in loaded_pyproject_toml:
|
|
77
|
+
result["KEEP_FIELDS"]["packaging"] = loaded_pyproject_toml["packaging"]
|
|
76
78
|
|
|
77
79
|
# Process dependencies
|
|
78
80
|
if "project" in loaded_pyproject_toml:
|
|
@@ -25,6 +25,7 @@ from {{ code_model.core_library }}.exceptions import DeserializationError
|
|
|
25
25
|
from {{ code_model.core_library }}{{ "" if code_model.is_azure_flavor else ".utils" }} import CaseInsensitiveEnumMeta
|
|
26
26
|
from {{ code_model.core_library }}.{{ "" if code_model.is_azure_flavor else "runtime." }}pipeline import PipelineResponse
|
|
27
27
|
from {{ code_model.core_library }}.serialization import _Null
|
|
28
|
+
from {{ code_model.core_library }}.rest import HttpResponse
|
|
28
29
|
|
|
29
30
|
_LOGGER = logging.getLogger(__name__)
|
|
30
31
|
|
|
@@ -935,13 +936,13 @@ def _deserialize(
|
|
|
935
936
|
|
|
936
937
|
def _failsafe_deserialize(
|
|
937
938
|
deserializer: typing.Any,
|
|
938
|
-
|
|
939
|
+
response: HttpResponse,
|
|
939
940
|
module: typing.Optional[str] = None,
|
|
940
941
|
rf: typing.Optional["_RestField"] = None,
|
|
941
942
|
format: typing.Optional[str] = None,
|
|
942
943
|
) -> typing.Any:
|
|
943
944
|
try:
|
|
944
|
-
return _deserialize(deserializer,
|
|
945
|
+
return _deserialize(deserializer, response.json(), module, rf, format)
|
|
945
946
|
except DeserializationError:
|
|
946
947
|
_LOGGER.warning(
|
|
947
948
|
"Ran into a deserialization error. Ignoring since this is failsafe deserialization",
|
|
@@ -952,10 +953,10 @@ def _failsafe_deserialize(
|
|
|
952
953
|
|
|
953
954
|
def _failsafe_deserialize_xml(
|
|
954
955
|
deserializer: typing.Any,
|
|
955
|
-
|
|
956
|
+
response: HttpResponse,
|
|
956
957
|
) -> typing.Any:
|
|
957
958
|
try:
|
|
958
|
-
return _deserialize_xml(deserializer,
|
|
959
|
+
return _deserialize_xml(deserializer, response.text())
|
|
959
960
|
except DeserializationError:
|
|
960
961
|
_LOGGER.warning(
|
|
961
962
|
"Ran into a deserialization error. Ignoring since this is failsafe deserialization",
|
package/generator/build/lib/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
{% endif %}
|
|
6
6
|
|
|
7
7
|
[build-system]
|
|
8
|
-
requires = ["setuptools>=
|
|
8
|
+
requires = ["setuptools>=77.0.3", "wheel"]
|
|
9
9
|
build-backend = "setuptools.build_meta"
|
|
10
10
|
|
|
11
11
|
[project]
|
|
@@ -14,8 +14,12 @@ name = "{{ options.get('package-name')|lower }}"
|
|
|
14
14
|
authors = [
|
|
15
15
|
{ name = "{{ code_model.company_name }}"{% if code_model.is_azure_flavor %}, email = "azpysdkhelp@microsoft.com"{% endif %} },
|
|
16
16
|
]
|
|
17
|
+
{% if options.get("azure-arm") %}
|
|
18
|
+
description = "Microsoft Azure {{ options.get('package-pprint-name') }} Client Library for Python"
|
|
19
|
+
{% else %}
|
|
17
20
|
description = "{{ code_model.company_name }} {% if code_model.is_azure_flavor and not options.get('package-pprint-name').startswith('Azure ') %}Azure {% endif %}{{ options.get('package-pprint-name') }} Client Library for Python"
|
|
18
|
-
|
|
21
|
+
{% endif %}
|
|
22
|
+
license = "MIT"
|
|
19
23
|
classifiers = [
|
|
20
24
|
"Development Status :: {{ dev_status }}",
|
|
21
25
|
"Programming Language :: Python",
|
|
@@ -24,7 +28,6 @@ classifiers = [
|
|
|
24
28
|
{% for version in range(min_version, max_version + 1) %}
|
|
25
29
|
"Programming Language :: Python :: 3.{{ version }}",
|
|
26
30
|
{% endfor %}
|
|
27
|
-
"License :: OSI Approved :: MIT License",
|
|
28
31
|
]
|
|
29
32
|
requires-python = ">={{ MIN_PYTHON_VERSION }}"
|
|
30
33
|
{% else %}
|
|
@@ -74,7 +77,7 @@ version = "{{ options.get("package-version", "unknown") }}"
|
|
|
74
77
|
{% if code_model.is_azure_flavor %}
|
|
75
78
|
|
|
76
79
|
[project.urls]
|
|
77
|
-
repository = "https://github.com/Azure/azure-sdk-for-python
|
|
80
|
+
repository = "https://github.com/Azure/azure-sdk-for-python"
|
|
78
81
|
{% endif %}
|
|
79
82
|
|
|
80
83
|
[tool.setuptools.dynamic]
|
|
@@ -85,13 +88,14 @@ version = {attr = "{{ code_model.namespace|lower }}._version.VERSION"}
|
|
|
85
88
|
version = {attr = "{{ options.get('package-name')|lower|replace('-', '.') }}._version.VERSION"}
|
|
86
89
|
{% endif %}
|
|
87
90
|
{% endif %}
|
|
88
|
-
readme = {file = ["README.md"], content-type = "text/markdown"}
|
|
91
|
+
readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"}
|
|
89
92
|
{% if options.get('package-mode') %}
|
|
90
93
|
|
|
91
94
|
[tool.setuptools.packages.find]
|
|
92
95
|
exclude = [
|
|
93
96
|
"tests*",
|
|
94
97
|
"samples*",
|
|
98
|
+
"doc*",
|
|
95
99
|
{% for pkgutil_name in pkgutil_names %}
|
|
96
100
|
"{{ pkgutil_name }}",
|
|
97
101
|
{% endfor %}
|
|
Binary file
|
|
@@ -46,7 +46,7 @@ class OptionsDict(MutableMapping):
|
|
|
46
46
|
self._data = options.copy() if options else {}
|
|
47
47
|
self._validate_combinations()
|
|
48
48
|
|
|
49
|
-
def __getitem__(self, key: str) -> Any:
|
|
49
|
+
def __getitem__(self, key: str) -> Any: # pylint: disable=too-many-return-statements
|
|
50
50
|
if key == "head-as-boolean" and self.get("azure-arm"):
|
|
51
51
|
# override to always true if azure-arm is set
|
|
52
52
|
return True
|
|
@@ -69,6 +69,9 @@ class OptionsDict(MutableMapping):
|
|
|
69
69
|
data = data[2:]
|
|
70
70
|
elif data.startswith("."):
|
|
71
71
|
data = data[1:]
|
|
72
|
+
# Remove trailing slashes
|
|
73
|
+
if data.endswith("/") or data.endswith("\\"):
|
|
74
|
+
data = data[:-1]
|
|
72
75
|
return data
|
|
73
76
|
return self._get_default(key)
|
|
74
77
|
|
|
@@ -106,7 +109,12 @@ class OptionsDict(MutableMapping):
|
|
|
106
109
|
if key == "combine-operation-files":
|
|
107
110
|
return self.get("version-tolerant")
|
|
108
111
|
if key == "package-pprint-name":
|
|
109
|
-
|
|
112
|
+
package_names = self.get("package-name", "").split("-")
|
|
113
|
+
return (
|
|
114
|
+
(package_names[-1].capitalize() + " Management")
|
|
115
|
+
if self.get("azure-arm")
|
|
116
|
+
else " ".join([i.capitalize() for i in package_names])
|
|
117
|
+
)
|
|
110
118
|
if key == "builders-visibility":
|
|
111
119
|
# Default to public if low-level client is not set, otherwise embedded
|
|
112
120
|
return "embedded" if not self.get("low-level-client") else "public"
|
|
@@ -149,9 +149,12 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
149
149
|
self._serialize_and_write_package_files()
|
|
150
150
|
|
|
151
151
|
# write apiview-properties.json
|
|
152
|
-
if
|
|
152
|
+
if (
|
|
153
|
+
self.code_model.options.get("emit-cross-language-definition-file")
|
|
154
|
+
and not self.code_model.options["multiapi"]
|
|
155
|
+
):
|
|
153
156
|
self.write_file(
|
|
154
|
-
|
|
157
|
+
self._root_of_sdk / Path("apiview-properties.json"),
|
|
155
158
|
general_serializer.serialize_cross_language_definition_file(),
|
|
156
159
|
)
|
|
157
160
|
|
|
@@ -165,7 +168,7 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
165
168
|
# add _metadata.json
|
|
166
169
|
if self.code_model.metadata:
|
|
167
170
|
self.write_file(
|
|
168
|
-
|
|
171
|
+
self._root_of_sdk / "_metadata.json",
|
|
169
172
|
json.dumps(self.code_model.metadata, indent=2),
|
|
170
173
|
)
|
|
171
174
|
elif client_namespace_type.clients:
|
|
@@ -216,11 +219,17 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
216
219
|
general_serializer.serialize_pkgutil_init_file(),
|
|
217
220
|
)
|
|
218
221
|
|
|
219
|
-
|
|
222
|
+
# path where README.md is
|
|
223
|
+
@property
|
|
224
|
+
def _root_of_sdk(self) -> Path:
|
|
220
225
|
root_of_sdk = Path(".")
|
|
221
226
|
if self.code_model.options["no-namespace-folders"]:
|
|
222
227
|
compensation = Path("../" * (self.code_model.namespace.count(".") + 1))
|
|
223
228
|
root_of_sdk = root_of_sdk / compensation
|
|
229
|
+
return root_of_sdk
|
|
230
|
+
|
|
231
|
+
def _serialize_and_write_package_files(self) -> None:
|
|
232
|
+
root_of_sdk = self._root_of_sdk
|
|
224
233
|
if self.code_model.options["package-mode"] in VALID_PACKAGE_MODE:
|
|
225
234
|
env = Environment(
|
|
226
235
|
loader=PackageLoader("pygen.codegen", "templates/packaging_templates"),
|
|
@@ -520,14 +529,14 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
520
529
|
namespace_config = get_namespace_config(self.code_model.namespace, self.code_model.options["multiapi"])
|
|
521
530
|
num_of_namespace = namespace_config.count(".") + 1
|
|
522
531
|
num_of_package_namespace = (
|
|
523
|
-
get_namespace_from_package_name(self.code_model.options.get("
|
|
532
|
+
get_namespace_from_package_name(self.code_model.options.get("package-name", "")).count(".") + 1
|
|
524
533
|
)
|
|
525
534
|
if num_of_namespace > num_of_package_namespace:
|
|
526
535
|
return Path("/".join(namespace_config.split(".")[num_of_package_namespace:]))
|
|
527
536
|
return Path("")
|
|
528
537
|
|
|
529
538
|
def _serialize_and_write_sample(self, env: Environment):
|
|
530
|
-
out_path =
|
|
539
|
+
out_path = self._root_of_sdk / "generated_samples"
|
|
531
540
|
for client in self.code_model.clients:
|
|
532
541
|
for op_group in client.operation_groups:
|
|
533
542
|
for operation in op_group.operations:
|
|
@@ -561,7 +570,7 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
561
570
|
|
|
562
571
|
def _serialize_and_write_test(self, env: Environment):
|
|
563
572
|
self.code_model.for_test = True
|
|
564
|
-
out_path =
|
|
573
|
+
out_path = self._root_of_sdk / "generated_tests"
|
|
565
574
|
general_serializer = TestGeneralSerializer(code_model=self.code_model, env=env)
|
|
566
575
|
self.write_file(out_path / "conftest.py", general_serializer.serialize_conftest())
|
|
567
576
|
if not self.code_model.options["azure-arm"]:
|
|
@@ -1032,7 +1032,7 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1032
1032
|
is_operation_file=True, skip_quote=True, serialize_namespace=self.serialize_namespace
|
|
1033
1033
|
)
|
|
1034
1034
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1035
|
-
retval.append(f" error = _failsafe_deserialize({type_annotation}, response
|
|
1035
|
+
retval.append(f" error = _failsafe_deserialize({type_annotation}, response)")
|
|
1036
1036
|
else:
|
|
1037
1037
|
retval.append(
|
|
1038
1038
|
f" error = self._deserialize.failsafe_deserialize({type_annotation}, "
|
|
@@ -1067,11 +1067,9 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1067
1067
|
)
|
|
1068
1068
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1069
1069
|
if xml_serializable(str(e.default_content_type)):
|
|
1070
|
-
retval.append(
|
|
1071
|
-
f" error = _failsafe_deserialize_xml({type_annotation}, response.text())"
|
|
1072
|
-
)
|
|
1070
|
+
retval.append(f" error = _failsafe_deserialize_xml({type_annotation}, response)")
|
|
1073
1071
|
else:
|
|
1074
|
-
retval.append(f" error = _failsafe_deserialize({type_annotation},
|
|
1072
|
+
retval.append(f" error = _failsafe_deserialize({type_annotation}, response)")
|
|
1075
1073
|
else:
|
|
1076
1074
|
retval.append(
|
|
1077
1075
|
f" error = self._deserialize.failsafe_deserialize({type_annotation}, "
|
|
@@ -1086,9 +1084,7 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1086
1084
|
if builder.non_default_errors:
|
|
1087
1085
|
retval.append(" else:")
|
|
1088
1086
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1089
|
-
retval.append(
|
|
1090
|
-
f"{indent}error = _failsafe_deserialize({default_error_deserialization}, response.json())"
|
|
1091
|
-
)
|
|
1087
|
+
retval.append(f"{indent}error = _failsafe_deserialize({default_error_deserialization}, response)")
|
|
1092
1088
|
else:
|
|
1093
1089
|
retval.append(
|
|
1094
1090
|
f"{indent}error = self._deserialize.failsafe_deserialize({default_error_deserialization}, "
|
|
@@ -70,9 +70,11 @@ class GeneralSerializer(BaseSerializer):
|
|
|
70
70
|
# If parsing the pyproject.toml fails, we assume the it does not exist or is incorrectly formatted.
|
|
71
71
|
return result
|
|
72
72
|
|
|
73
|
-
# Keep azure-sdk-build configuration
|
|
73
|
+
# Keep "azure-sdk-build" and "packaging" configuration
|
|
74
74
|
if "tool" in loaded_pyproject_toml and "azure-sdk-build" in loaded_pyproject_toml["tool"]:
|
|
75
75
|
result["KEEP_FIELDS"]["tool.azure-sdk-build"] = loaded_pyproject_toml["tool"]["azure-sdk-build"]
|
|
76
|
+
if "packaging" in loaded_pyproject_toml:
|
|
77
|
+
result["KEEP_FIELDS"]["packaging"] = loaded_pyproject_toml["packaging"]
|
|
76
78
|
|
|
77
79
|
# Process dependencies
|
|
78
80
|
if "project" in loaded_pyproject_toml:
|
|
@@ -25,6 +25,7 @@ from {{ code_model.core_library }}.exceptions import DeserializationError
|
|
|
25
25
|
from {{ code_model.core_library }}{{ "" if code_model.is_azure_flavor else ".utils" }} import CaseInsensitiveEnumMeta
|
|
26
26
|
from {{ code_model.core_library }}.{{ "" if code_model.is_azure_flavor else "runtime." }}pipeline import PipelineResponse
|
|
27
27
|
from {{ code_model.core_library }}.serialization import _Null
|
|
28
|
+
from {{ code_model.core_library }}.rest import HttpResponse
|
|
28
29
|
|
|
29
30
|
_LOGGER = logging.getLogger(__name__)
|
|
30
31
|
|
|
@@ -935,13 +936,13 @@ def _deserialize(
|
|
|
935
936
|
|
|
936
937
|
def _failsafe_deserialize(
|
|
937
938
|
deserializer: typing.Any,
|
|
938
|
-
|
|
939
|
+
response: HttpResponse,
|
|
939
940
|
module: typing.Optional[str] = None,
|
|
940
941
|
rf: typing.Optional["_RestField"] = None,
|
|
941
942
|
format: typing.Optional[str] = None,
|
|
942
943
|
) -> typing.Any:
|
|
943
944
|
try:
|
|
944
|
-
return _deserialize(deserializer,
|
|
945
|
+
return _deserialize(deserializer, response.json(), module, rf, format)
|
|
945
946
|
except DeserializationError:
|
|
946
947
|
_LOGGER.warning(
|
|
947
948
|
"Ran into a deserialization error. Ignoring since this is failsafe deserialization",
|
|
@@ -952,10 +953,10 @@ def _failsafe_deserialize(
|
|
|
952
953
|
|
|
953
954
|
def _failsafe_deserialize_xml(
|
|
954
955
|
deserializer: typing.Any,
|
|
955
|
-
|
|
956
|
+
response: HttpResponse,
|
|
956
957
|
) -> typing.Any:
|
|
957
958
|
try:
|
|
958
|
-
return _deserialize_xml(deserializer,
|
|
959
|
+
return _deserialize_xml(deserializer, response.text())
|
|
959
960
|
except DeserializationError:
|
|
960
961
|
_LOGGER.warning(
|
|
961
962
|
"Ran into a deserialization error. Ignoring since this is failsafe deserialization",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
{% endif %}
|
|
6
6
|
|
|
7
7
|
[build-system]
|
|
8
|
-
requires = ["setuptools>=
|
|
8
|
+
requires = ["setuptools>=77.0.3", "wheel"]
|
|
9
9
|
build-backend = "setuptools.build_meta"
|
|
10
10
|
|
|
11
11
|
[project]
|
|
@@ -14,8 +14,12 @@ name = "{{ options.get('package-name')|lower }}"
|
|
|
14
14
|
authors = [
|
|
15
15
|
{ name = "{{ code_model.company_name }}"{% if code_model.is_azure_flavor %}, email = "azpysdkhelp@microsoft.com"{% endif %} },
|
|
16
16
|
]
|
|
17
|
+
{% if options.get("azure-arm") %}
|
|
18
|
+
description = "Microsoft Azure {{ options.get('package-pprint-name') }} Client Library for Python"
|
|
19
|
+
{% else %}
|
|
17
20
|
description = "{{ code_model.company_name }} {% if code_model.is_azure_flavor and not options.get('package-pprint-name').startswith('Azure ') %}Azure {% endif %}{{ options.get('package-pprint-name') }} Client Library for Python"
|
|
18
|
-
|
|
21
|
+
{% endif %}
|
|
22
|
+
license = "MIT"
|
|
19
23
|
classifiers = [
|
|
20
24
|
"Development Status :: {{ dev_status }}",
|
|
21
25
|
"Programming Language :: Python",
|
|
@@ -24,7 +28,6 @@ classifiers = [
|
|
|
24
28
|
{% for version in range(min_version, max_version + 1) %}
|
|
25
29
|
"Programming Language :: Python :: 3.{{ version }}",
|
|
26
30
|
{% endfor %}
|
|
27
|
-
"License :: OSI Approved :: MIT License",
|
|
28
31
|
]
|
|
29
32
|
requires-python = ">={{ MIN_PYTHON_VERSION }}"
|
|
30
33
|
{% else %}
|
|
@@ -74,7 +77,7 @@ version = "{{ options.get("package-version", "unknown") }}"
|
|
|
74
77
|
{% if code_model.is_azure_flavor %}
|
|
75
78
|
|
|
76
79
|
[project.urls]
|
|
77
|
-
repository = "https://github.com/Azure/azure-sdk-for-python
|
|
80
|
+
repository = "https://github.com/Azure/azure-sdk-for-python"
|
|
78
81
|
{% endif %}
|
|
79
82
|
|
|
80
83
|
[tool.setuptools.dynamic]
|
|
@@ -85,13 +88,14 @@ version = {attr = "{{ code_model.namespace|lower }}._version.VERSION"}
|
|
|
85
88
|
version = {attr = "{{ options.get('package-name')|lower|replace('-', '.') }}._version.VERSION"}
|
|
86
89
|
{% endif %}
|
|
87
90
|
{% endif %}
|
|
88
|
-
readme = {file = ["README.md"], content-type = "text/markdown"}
|
|
91
|
+
readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"}
|
|
89
92
|
{% if options.get('package-mode') %}
|
|
90
93
|
|
|
91
94
|
[tool.setuptools.packages.find]
|
|
92
95
|
exclude = [
|
|
93
96
|
"tests*",
|
|
94
97
|
"samples*",
|
|
98
|
+
"doc*",
|
|
95
99
|
{% for pkgutil_name in pkgutil_names %}
|
|
96
100
|
"{{ pkgutil_name }}",
|
|
97
101
|
{% endfor %}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "6.38.
|
|
3
|
+
"version": "6.38.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.15.
|
|
22
|
+
"@typespec/http-client-python": "~0.15.2",
|
|
23
23
|
"@autorest/system-requirements": "~1.0.2",
|
|
24
24
|
"fs-extra": "~11.2.0",
|
|
25
25
|
"tsx": "~4.19.1"
|
|
Binary file
|