@autorest/python 6.34.2 → 6.35.1
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/multiapi/models/client.py +1 -1
- package/autorest/multiapi/serializers/__init__.py +1 -5
- package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +1 -1
- package/generator/build/lib/pygen/codegen/models/client.py +1 -0
- package/generator/build/lib/pygen/codegen/models/code_model.py +1 -0
- package/generator/build/lib/pygen/codegen/models/paging_operation.py +10 -2
- package/generator/build/lib/pygen/codegen/models/response.py +1 -1
- package/generator/build/lib/pygen/codegen/serializers/__init__.py +8 -0
- package/generator/build/lib/pygen/codegen/serializers/general_serializer.py +1 -1
- package/generator/build/lib/pygen/codegen/templates/packaging_templates/README.md.jinja2 +1 -1
- package/generator/component-detection-pip-report.json +14 -8
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/client.py +1 -0
- package/generator/pygen/codegen/models/code_model.py +1 -0
- package/generator/pygen/codegen/models/paging_operation.py +10 -2
- package/generator/pygen/codegen/models/response.py +1 -1
- package/generator/pygen/codegen/serializers/__init__.py +8 -0
- package/generator/pygen/codegen/serializers/general_serializer.py +1 -1
- package/generator/pygen/codegen/templates/packaging_templates/README.md.jinja2 +1 -1
- package/package.json +2 -2
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
- package/autorest/multiapi/templates/multiapi_utils_init.py.jinja2 +0 -10
|
@@ -43,7 +43,7 @@ class Client:
|
|
|
43
43
|
file_import = FileImport(json.loads(self.default_version_metadata["client"][imports_to_load]))
|
|
44
44
|
local_imports = file_import.imports.get(TypingSection.REGULAR, {}).get(ImportType.LOCAL, {})
|
|
45
45
|
for key in local_imports:
|
|
46
|
-
if re.search("^\\.*
|
|
46
|
+
if re.search("^\\.*_utils.serialization$", key):
|
|
47
47
|
relative_path = ".." if async_mode else "."
|
|
48
48
|
local_imports[f"{relative_path}_serialization"] = local_imports.pop(key)
|
|
49
49
|
break
|
|
@@ -133,11 +133,7 @@ class MultiAPISerializer(ReaderAndWriter): # pylint: disable=abstract-method
|
|
|
133
133
|
lstrip_blocks=True,
|
|
134
134
|
)
|
|
135
135
|
self.write_file(
|
|
136
|
-
Path("
|
|
137
|
-
self.env.get_template("multiapi_utils_init.py.jinja2").render(),
|
|
138
|
-
)
|
|
139
|
-
self.write_file(
|
|
140
|
-
Path("_utils/serialization.py"),
|
|
136
|
+
Path("_serialization.py"),
|
|
141
137
|
codegen_env.get_template("serialization.py.jinja2").render(
|
|
142
138
|
code_model=code_model,
|
|
143
139
|
),
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
# Changes may cause incorrect behavior and will be lost if the code is
|
|
9
9
|
# regenerated.
|
|
10
10
|
# --------------------------------------------------------------------------
|
|
11
|
-
from {{ ".." if async_mode else "." }}
|
|
11
|
+
from {{ ".." if async_mode else "." }}_serialization import Serializer, Deserializer
|
|
12
12
|
{% if imports %}
|
|
13
13
|
{{ imports }}
|
|
14
14
|
{% endif %}
|
|
@@ -173,6 +173,7 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]): # pylint: disable=t
|
|
|
173
173
|
p
|
|
174
174
|
for p in self.parameters.parameters
|
|
175
175
|
if p.is_api_version
|
|
176
|
+
and p.client_name == "api_version"
|
|
176
177
|
and p.method_location in [ParameterMethodLocation.KEYWORD_ONLY, ParameterMethodLocation.KWARG]
|
|
177
178
|
):
|
|
178
179
|
retval = add_to_pylint_disable(retval, "client-accepts-api-version-keyword")
|
|
@@ -98,6 +98,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
98
98
|
self.has_subnamespace = False
|
|
99
99
|
self._operations_folder_name: Dict[str, str] = {}
|
|
100
100
|
self._relative_import_path: Dict[str, str] = {}
|
|
101
|
+
self.metadata: Dict[str, Any] = yaml_data.get("metadata", {})
|
|
101
102
|
|
|
102
103
|
@staticmethod
|
|
103
104
|
def get_imported_namespace_for_client(imported_namespace: str, async_mode: bool = False) -> str:
|
|
@@ -122,9 +122,17 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
122
122
|
def _imports_shared(self, async_mode: bool, **kwargs: Any) -> FileImport:
|
|
123
123
|
file_import = super()._imports_shared(async_mode, **kwargs)
|
|
124
124
|
if async_mode:
|
|
125
|
-
|
|
125
|
+
default_paging_submodule = f"{'async_' if self.code_model.is_azure_flavor else ''}paging"
|
|
126
|
+
file_import.add_submodule_import(
|
|
127
|
+
f"{self.code_model.core_library}.{default_paging_submodule}",
|
|
128
|
+
"AsyncItemPaged",
|
|
129
|
+
ImportType.SDKCORE,
|
|
130
|
+
TypingSection.CONDITIONAL,
|
|
131
|
+
)
|
|
126
132
|
else:
|
|
127
|
-
file_import.add_submodule_import(
|
|
133
|
+
file_import.add_submodule_import(
|
|
134
|
+
f"{self.code_model.core_library}.paging", "ItemPaged", ImportType.SDKCORE, TypingSection.CONDITIONAL
|
|
135
|
+
)
|
|
128
136
|
if (
|
|
129
137
|
self.next_request_builder
|
|
130
138
|
and self.code_model.options["builders_visibility"] == "embedded"
|
|
@@ -186,7 +186,7 @@ class PagingResponse(Response):
|
|
|
186
186
|
return self.get_pager_path(async_mode).split(".")[-1]
|
|
187
187
|
|
|
188
188
|
def type_annotation(self, **kwargs: Any) -> str:
|
|
189
|
-
iterable = "
|
|
189
|
+
iterable = "AsyncItemPaged" if kwargs["async_mode"] else "ItemPaged"
|
|
190
190
|
return f"{iterable}[{self.item_type.type_annotation(**kwargs)}]"
|
|
191
191
|
|
|
192
192
|
def docstring_text(self, **kwargs: Any) -> str:
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import logging
|
|
7
|
+
import json
|
|
7
8
|
from collections import namedtuple
|
|
8
9
|
import re
|
|
9
10
|
from typing import List, Any, Union
|
|
@@ -143,6 +144,13 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
143
144
|
self._serialize_and_write_sample(env, namespace=client_namespace)
|
|
144
145
|
if self.code_model.options["generate_test"]:
|
|
145
146
|
self._serialize_and_write_test(env, namespace=client_namespace)
|
|
147
|
+
|
|
148
|
+
# add _metadata.json
|
|
149
|
+
if self.code_model.metadata:
|
|
150
|
+
self.write_file(
|
|
151
|
+
exec_path / Path("_metadata.json"),
|
|
152
|
+
json.dumps(self.code_model.metadata, indent=2),
|
|
153
|
+
)
|
|
146
154
|
elif client_namespace_type.clients:
|
|
147
155
|
# add clients folder if there are clients in this namespace
|
|
148
156
|
self._serialize_client_and_config_files(client_namespace, client_namespace_type.clients, env)
|
|
@@ -63,7 +63,7 @@ class GeneralSerializer(BaseSerializer):
|
|
|
63
63
|
"token_credential": token_credential,
|
|
64
64
|
"pkgutil_names": [".".join(package_parts[: i + 1]) for i in range(len(package_parts))],
|
|
65
65
|
"init_names": ["/".join(package_parts[: i + 1]) + "/__init__.py" for i in range(len(package_parts))],
|
|
66
|
-
"client_name": self.code_model.clients[0].name,
|
|
66
|
+
"client_name": self.code_model.clients[0].name if self.code_model.clients else "",
|
|
67
67
|
"VERSION_MAP": VERSION_MAP,
|
|
68
68
|
"MIN_PYTHON_VERSION": MIN_PYTHON_VERSION,
|
|
69
69
|
"MAX_PYTHON_VERSION": MAX_PYTHON_VERSION,
|
|
@@ -40,7 +40,7 @@ python -m pip install {{ package_name }}
|
|
|
40
40
|
- You need an [Azure subscription][azure_sub] to use this package.
|
|
41
41
|
- An existing {{ package_pprint_name }} instance.
|
|
42
42
|
|
|
43
|
-
{% if token_credential %}
|
|
43
|
+
{% if token_credential and client_name %}
|
|
44
44
|
#### Create with an Azure Active Directory Credential
|
|
45
45
|
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
|
|
46
46
|
provide an instance of the desired credential type obtained from the
|
|
@@ -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/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl",
|
|
8
8
|
"archive_info": {
|
|
9
|
-
"hash": "sha256=
|
|
9
|
+
"hash": "sha256=062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922",
|
|
10
10
|
"hashes": {
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -18,7 +18,10 @@
|
|
|
18
18
|
"metadata": {
|
|
19
19
|
"metadata_version": "2.4",
|
|
20
20
|
"name": "setuptools",
|
|
21
|
-
"version": "80.
|
|
21
|
+
"version": "80.9.0",
|
|
22
|
+
"dynamic": [
|
|
23
|
+
"license-file"
|
|
24
|
+
],
|
|
22
25
|
"summary": "Easily download, build, install, upgrade, and uninstall Python packages",
|
|
23
26
|
"description_content_type": "text/x-rst",
|
|
24
27
|
"keywords": [
|
|
@@ -31,6 +34,9 @@
|
|
|
31
34
|
],
|
|
32
35
|
"author_email": "Python Packaging Authority <distutils-sig@python.org>",
|
|
33
36
|
"license_expression": "MIT",
|
|
37
|
+
"license_file": [
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
34
40
|
"classifier": [
|
|
35
41
|
"Development Status :: 5 - Production/Stable",
|
|
36
42
|
"Intended Audience :: Developers",
|
|
@@ -117,13 +123,13 @@
|
|
|
117
123
|
],
|
|
118
124
|
"environment": {
|
|
119
125
|
"implementation_name": "cpython",
|
|
120
|
-
"implementation_version": "3.9.
|
|
126
|
+
"implementation_version": "3.9.22",
|
|
121
127
|
"os_name": "posix",
|
|
122
128
|
"platform_machine": "x86_64",
|
|
123
|
-
"platform_release": "
|
|
129
|
+
"platform_release": "6.11.0-1015-azure",
|
|
124
130
|
"platform_system": "Linux",
|
|
125
|
-
"platform_version": "#
|
|
126
|
-
"python_full_version": "3.9.
|
|
131
|
+
"platform_version": "#15~24.04.1-Ubuntu SMP Thu May 1 02:52:08 UTC 2025",
|
|
132
|
+
"python_full_version": "3.9.22",
|
|
127
133
|
"platform_python_implementation": "CPython",
|
|
128
134
|
"python_version": "3.9",
|
|
129
135
|
"sys_platform": "linux"
|
|
Binary file
|
|
@@ -173,6 +173,7 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]): # pylint: disable=t
|
|
|
173
173
|
p
|
|
174
174
|
for p in self.parameters.parameters
|
|
175
175
|
if p.is_api_version
|
|
176
|
+
and p.client_name == "api_version"
|
|
176
177
|
and p.method_location in [ParameterMethodLocation.KEYWORD_ONLY, ParameterMethodLocation.KWARG]
|
|
177
178
|
):
|
|
178
179
|
retval = add_to_pylint_disable(retval, "client-accepts-api-version-keyword")
|
|
@@ -98,6 +98,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
98
98
|
self.has_subnamespace = False
|
|
99
99
|
self._operations_folder_name: Dict[str, str] = {}
|
|
100
100
|
self._relative_import_path: Dict[str, str] = {}
|
|
101
|
+
self.metadata: Dict[str, Any] = yaml_data.get("metadata", {})
|
|
101
102
|
|
|
102
103
|
@staticmethod
|
|
103
104
|
def get_imported_namespace_for_client(imported_namespace: str, async_mode: bool = False) -> str:
|
|
@@ -122,9 +122,17 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
122
122
|
def _imports_shared(self, async_mode: bool, **kwargs: Any) -> FileImport:
|
|
123
123
|
file_import = super()._imports_shared(async_mode, **kwargs)
|
|
124
124
|
if async_mode:
|
|
125
|
-
|
|
125
|
+
default_paging_submodule = f"{'async_' if self.code_model.is_azure_flavor else ''}paging"
|
|
126
|
+
file_import.add_submodule_import(
|
|
127
|
+
f"{self.code_model.core_library}.{default_paging_submodule}",
|
|
128
|
+
"AsyncItemPaged",
|
|
129
|
+
ImportType.SDKCORE,
|
|
130
|
+
TypingSection.CONDITIONAL,
|
|
131
|
+
)
|
|
126
132
|
else:
|
|
127
|
-
file_import.add_submodule_import(
|
|
133
|
+
file_import.add_submodule_import(
|
|
134
|
+
f"{self.code_model.core_library}.paging", "ItemPaged", ImportType.SDKCORE, TypingSection.CONDITIONAL
|
|
135
|
+
)
|
|
128
136
|
if (
|
|
129
137
|
self.next_request_builder
|
|
130
138
|
and self.code_model.options["builders_visibility"] == "embedded"
|
|
@@ -186,7 +186,7 @@ class PagingResponse(Response):
|
|
|
186
186
|
return self.get_pager_path(async_mode).split(".")[-1]
|
|
187
187
|
|
|
188
188
|
def type_annotation(self, **kwargs: Any) -> str:
|
|
189
|
-
iterable = "
|
|
189
|
+
iterable = "AsyncItemPaged" if kwargs["async_mode"] else "ItemPaged"
|
|
190
190
|
return f"{iterable}[{self.item_type.type_annotation(**kwargs)}]"
|
|
191
191
|
|
|
192
192
|
def docstring_text(self, **kwargs: Any) -> str:
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import logging
|
|
7
|
+
import json
|
|
7
8
|
from collections import namedtuple
|
|
8
9
|
import re
|
|
9
10
|
from typing import List, Any, Union
|
|
@@ -143,6 +144,13 @@ class JinjaSerializer(ReaderAndWriter):
|
|
|
143
144
|
self._serialize_and_write_sample(env, namespace=client_namespace)
|
|
144
145
|
if self.code_model.options["generate_test"]:
|
|
145
146
|
self._serialize_and_write_test(env, namespace=client_namespace)
|
|
147
|
+
|
|
148
|
+
# add _metadata.json
|
|
149
|
+
if self.code_model.metadata:
|
|
150
|
+
self.write_file(
|
|
151
|
+
exec_path / Path("_metadata.json"),
|
|
152
|
+
json.dumps(self.code_model.metadata, indent=2),
|
|
153
|
+
)
|
|
146
154
|
elif client_namespace_type.clients:
|
|
147
155
|
# add clients folder if there are clients in this namespace
|
|
148
156
|
self._serialize_client_and_config_files(client_namespace, client_namespace_type.clients, env)
|
|
@@ -63,7 +63,7 @@ class GeneralSerializer(BaseSerializer):
|
|
|
63
63
|
"token_credential": token_credential,
|
|
64
64
|
"pkgutil_names": [".".join(package_parts[: i + 1]) for i in range(len(package_parts))],
|
|
65
65
|
"init_names": ["/".join(package_parts[: i + 1]) + "/__init__.py" for i in range(len(package_parts))],
|
|
66
|
-
"client_name": self.code_model.clients[0].name,
|
|
66
|
+
"client_name": self.code_model.clients[0].name if self.code_model.clients else "",
|
|
67
67
|
"VERSION_MAP": VERSION_MAP,
|
|
68
68
|
"MIN_PYTHON_VERSION": MIN_PYTHON_VERSION,
|
|
69
69
|
"MAX_PYTHON_VERSION": MAX_PYTHON_VERSION,
|
|
@@ -40,7 +40,7 @@ python -m pip install {{ package_name }}
|
|
|
40
40
|
- You need an [Azure subscription][azure_sub] to use this package.
|
|
41
41
|
- An existing {{ package_pprint_name }} instance.
|
|
42
42
|
|
|
43
|
-
{% if token_credential %}
|
|
43
|
+
{% if token_credential and client_name %}
|
|
44
44
|
#### Create with an Azure Active Directory Credential
|
|
45
45
|
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
|
|
46
46
|
provide an instance of the desired credential type obtained from the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.35.1",
|
|
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.12.1",
|
|
23
23
|
"@autorest/system-requirements": "~1.0.2",
|
|
24
24
|
"fs-extra": "~11.2.0",
|
|
25
25
|
"tsx": "~4.19.1"
|
|
Binary file
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# coding=utf-8
|
|
2
|
-
# --------------------------------------------------------------------------
|
|
3
|
-
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
# Licensed under the MIT License. See License.txt in the project root for
|
|
5
|
-
# license information.
|
|
6
|
-
#
|
|
7
|
-
# Code generated by Microsoft (R) AutoRest Code Generator.
|
|
8
|
-
# Changes may cause incorrect behavior and will be lost if the code is
|
|
9
|
-
# regenerated.
|
|
10
|
-
# --------------------------------------------------------------------------
|