@autorest/python 6.41.0 → 6.41.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/codegen/models/operation.py +5 -1
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +22 -6
- package/generator/build/lib/pygen/codegen/serializers/model_init_serializer.py +5 -2
- package/generator/build/lib/pygen/codegen/templates/model_init.py.jinja2 +6 -0
- package/generator/build/lib/pygen/codegen/templates/operation_tools.jinja2 +2 -1
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/operation.py +5 -1
- package/generator/pygen/codegen/serializers/builder_serializer.py +22 -6
- package/generator/pygen/codegen/serializers/model_init_serializer.py +5 -2
- package/generator/pygen/codegen/templates/model_init.py.jinja2 +6 -0
- package/generator/pygen/codegen/templates/operation_tools.jinja2 +2 -1
- package/package.json +2 -2
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
|
@@ -198,7 +198,11 @@ class OperationBase( # pylint: disable=too-many-public-methods,too-many-instanc
|
|
|
198
198
|
return None
|
|
199
199
|
exception_schema = default_exceptions[0].type
|
|
200
200
|
if isinstance(exception_schema, ModelType):
|
|
201
|
-
|
|
201
|
+
pylint_disable = " # pylint: disable=protected-access" if exception_schema.internal else ""
|
|
202
|
+
return (
|
|
203
|
+
exception_schema.type_annotation(skip_quote=True, serialize_namespace=serialize_namespace)
|
|
204
|
+
+ pylint_disable
|
|
205
|
+
)
|
|
202
206
|
return None if self.code_model.options["models-mode"] == "dpg" else "'object'"
|
|
203
207
|
|
|
204
208
|
@property
|
|
@@ -1014,7 +1014,9 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1014
1014
|
retval.extend(deserialize_code)
|
|
1015
1015
|
return retval
|
|
1016
1016
|
|
|
1017
|
-
def handle_error_response(
|
|
1017
|
+
def handle_error_response( # pylint: disable=too-many-statements, too-many-branches
|
|
1018
|
+
self, builder: OperationType
|
|
1019
|
+
) -> list[str]:
|
|
1018
1020
|
async_await = "await " if self.async_mode else ""
|
|
1019
1021
|
retval = [f"if response.status_code not in {str(builder.success_status_codes)}:"]
|
|
1020
1022
|
response_read = [
|
|
@@ -1036,6 +1038,10 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1036
1038
|
retval.append(" error = None")
|
|
1037
1039
|
for e in builder.non_default_errors:
|
|
1038
1040
|
# single status code
|
|
1041
|
+
if isinstance(e.type, ModelType) and e.type.internal:
|
|
1042
|
+
pylint_disable = " # pylint: disable=protected-access"
|
|
1043
|
+
else:
|
|
1044
|
+
pylint_disable = ""
|
|
1039
1045
|
if isinstance(e.status_codes[0], int):
|
|
1040
1046
|
for status_code in e.status_codes:
|
|
1041
1047
|
retval.append(f" {condition} response.status_code == {status_code}:")
|
|
@@ -1043,10 +1049,13 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1043
1049
|
is_operation_file=True, skip_quote=True, serialize_namespace=self.serialize_namespace
|
|
1044
1050
|
)
|
|
1045
1051
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1046
|
-
retval.append(
|
|
1052
|
+
retval.append(
|
|
1053
|
+
f" error = _failsafe_deserialize({type_annotation},{pylint_disable}\n response)"
|
|
1054
|
+
)
|
|
1047
1055
|
else:
|
|
1048
1056
|
retval.append(
|
|
1049
|
-
|
|
1057
|
+
" error = self._deserialize.failsafe_deserialize("
|
|
1058
|
+
f"{type_annotation},{pylint_disable}\n "
|
|
1050
1059
|
"pipeline_response)"
|
|
1051
1060
|
)
|
|
1052
1061
|
# add build-in error type
|
|
@@ -1078,12 +1087,19 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1078
1087
|
)
|
|
1079
1088
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1080
1089
|
if xml_serializable(str(e.default_content_type)):
|
|
1081
|
-
retval.append(
|
|
1090
|
+
retval.append(
|
|
1091
|
+
" error = _failsafe_deserialize_xml("
|
|
1092
|
+
f"{type_annotation},{pylint_disable}\n response)"
|
|
1093
|
+
)
|
|
1082
1094
|
else:
|
|
1083
|
-
retval.append(
|
|
1095
|
+
retval.append(
|
|
1096
|
+
" error = _failsafe_deserialize("
|
|
1097
|
+
f"{type_annotation},{pylint_disable}\n response)"
|
|
1098
|
+
)
|
|
1084
1099
|
else:
|
|
1085
1100
|
retval.append(
|
|
1086
|
-
|
|
1101
|
+
" error = self._deserialize.failsafe_deserialize("
|
|
1102
|
+
f"{type_annotation},{pylint_disable}\n "
|
|
1087
1103
|
"pipeline_response)"
|
|
1088
1104
|
)
|
|
1089
1105
|
condition = "elif"
|
|
@@ -32,6 +32,9 @@ class ModelInitSerializer:
|
|
|
32
32
|
", ".join(model_enum_name_intersection)
|
|
33
33
|
)
|
|
34
34
|
)
|
|
35
|
-
|
|
35
|
+
has_models = self.models
|
|
36
|
+
has_enums = self.enums
|
|
36
37
|
template = self.env.get_template("model_init.py.jinja2")
|
|
37
|
-
return template.render(
|
|
38
|
+
return template.render(
|
|
39
|
+
code_model=self.code_model, schemas=schemas, enums=enums, has_models=has_models, has_enums=has_enums
|
|
40
|
+
)
|
|
@@ -11,6 +11,9 @@ from .{{ code_model.models_filename }} import ( # type: ignore
|
|
|
11
11
|
{{ schema }},
|
|
12
12
|
{% endfor %}
|
|
13
13
|
)
|
|
14
|
+
{% elif has_models %}
|
|
15
|
+
|
|
16
|
+
from . import _models
|
|
14
17
|
{% endif %}
|
|
15
18
|
{% if enums %}
|
|
16
19
|
|
|
@@ -19,6 +22,9 @@ from .{{ code_model.enums_filename }} import ( # type: ignore
|
|
|
19
22
|
{{ enum }},
|
|
20
23
|
{% endfor %}
|
|
21
24
|
)
|
|
25
|
+
{% elif has_enums %}
|
|
26
|
+
|
|
27
|
+
from . import _enums
|
|
22
28
|
{% endif %}
|
|
23
29
|
{{ keywords.patch_imports() }}
|
|
24
30
|
__all__ = [
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
{% endfor %}
|
|
20
20
|
{% for description in param_description_and_response_docstring %}
|
|
21
21
|
{% if description %}
|
|
22
|
-
{
|
|
22
|
+
{% set description = wrap_string(description, wrapstring='\n ') %}
|
|
23
|
+
{{ " " if description[0] != ":" and description[0] != " " else "" }}{{ description}}
|
|
23
24
|
{% else %}
|
|
24
25
|
|
|
25
26
|
{% endif %}
|
|
Binary file
|
|
@@ -198,7 +198,11 @@ class OperationBase( # pylint: disable=too-many-public-methods,too-many-instanc
|
|
|
198
198
|
return None
|
|
199
199
|
exception_schema = default_exceptions[0].type
|
|
200
200
|
if isinstance(exception_schema, ModelType):
|
|
201
|
-
|
|
201
|
+
pylint_disable = " # pylint: disable=protected-access" if exception_schema.internal else ""
|
|
202
|
+
return (
|
|
203
|
+
exception_schema.type_annotation(skip_quote=True, serialize_namespace=serialize_namespace)
|
|
204
|
+
+ pylint_disable
|
|
205
|
+
)
|
|
202
206
|
return None if self.code_model.options["models-mode"] == "dpg" else "'object'"
|
|
203
207
|
|
|
204
208
|
@property
|
|
@@ -1014,7 +1014,9 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1014
1014
|
retval.extend(deserialize_code)
|
|
1015
1015
|
return retval
|
|
1016
1016
|
|
|
1017
|
-
def handle_error_response(
|
|
1017
|
+
def handle_error_response( # pylint: disable=too-many-statements, too-many-branches
|
|
1018
|
+
self, builder: OperationType
|
|
1019
|
+
) -> list[str]:
|
|
1018
1020
|
async_await = "await " if self.async_mode else ""
|
|
1019
1021
|
retval = [f"if response.status_code not in {str(builder.success_status_codes)}:"]
|
|
1020
1022
|
response_read = [
|
|
@@ -1036,6 +1038,10 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1036
1038
|
retval.append(" error = None")
|
|
1037
1039
|
for e in builder.non_default_errors:
|
|
1038
1040
|
# single status code
|
|
1041
|
+
if isinstance(e.type, ModelType) and e.type.internal:
|
|
1042
|
+
pylint_disable = " # pylint: disable=protected-access"
|
|
1043
|
+
else:
|
|
1044
|
+
pylint_disable = ""
|
|
1039
1045
|
if isinstance(e.status_codes[0], int):
|
|
1040
1046
|
for status_code in e.status_codes:
|
|
1041
1047
|
retval.append(f" {condition} response.status_code == {status_code}:")
|
|
@@ -1043,10 +1049,13 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1043
1049
|
is_operation_file=True, skip_quote=True, serialize_namespace=self.serialize_namespace
|
|
1044
1050
|
)
|
|
1045
1051
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1046
|
-
retval.append(
|
|
1052
|
+
retval.append(
|
|
1053
|
+
f" error = _failsafe_deserialize({type_annotation},{pylint_disable}\n response)"
|
|
1054
|
+
)
|
|
1047
1055
|
else:
|
|
1048
1056
|
retval.append(
|
|
1049
|
-
|
|
1057
|
+
" error = self._deserialize.failsafe_deserialize("
|
|
1058
|
+
f"{type_annotation},{pylint_disable}\n "
|
|
1050
1059
|
"pipeline_response)"
|
|
1051
1060
|
)
|
|
1052
1061
|
# add build-in error type
|
|
@@ -1078,12 +1087,19 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1078
1087
|
)
|
|
1079
1088
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1080
1089
|
if xml_serializable(str(e.default_content_type)):
|
|
1081
|
-
retval.append(
|
|
1090
|
+
retval.append(
|
|
1091
|
+
" error = _failsafe_deserialize_xml("
|
|
1092
|
+
f"{type_annotation},{pylint_disable}\n response)"
|
|
1093
|
+
)
|
|
1082
1094
|
else:
|
|
1083
|
-
retval.append(
|
|
1095
|
+
retval.append(
|
|
1096
|
+
" error = _failsafe_deserialize("
|
|
1097
|
+
f"{type_annotation},{pylint_disable}\n response)"
|
|
1098
|
+
)
|
|
1084
1099
|
else:
|
|
1085
1100
|
retval.append(
|
|
1086
|
-
|
|
1101
|
+
" error = self._deserialize.failsafe_deserialize("
|
|
1102
|
+
f"{type_annotation},{pylint_disable}\n "
|
|
1087
1103
|
"pipeline_response)"
|
|
1088
1104
|
)
|
|
1089
1105
|
condition = "elif"
|
|
@@ -32,6 +32,9 @@ class ModelInitSerializer:
|
|
|
32
32
|
", ".join(model_enum_name_intersection)
|
|
33
33
|
)
|
|
34
34
|
)
|
|
35
|
-
|
|
35
|
+
has_models = self.models
|
|
36
|
+
has_enums = self.enums
|
|
36
37
|
template = self.env.get_template("model_init.py.jinja2")
|
|
37
|
-
return template.render(
|
|
38
|
+
return template.render(
|
|
39
|
+
code_model=self.code_model, schemas=schemas, enums=enums, has_models=has_models, has_enums=has_enums
|
|
40
|
+
)
|
|
@@ -11,6 +11,9 @@ from .{{ code_model.models_filename }} import ( # type: ignore
|
|
|
11
11
|
{{ schema }},
|
|
12
12
|
{% endfor %}
|
|
13
13
|
)
|
|
14
|
+
{% elif has_models %}
|
|
15
|
+
|
|
16
|
+
from . import _models
|
|
14
17
|
{% endif %}
|
|
15
18
|
{% if enums %}
|
|
16
19
|
|
|
@@ -19,6 +22,9 @@ from .{{ code_model.enums_filename }} import ( # type: ignore
|
|
|
19
22
|
{{ enum }},
|
|
20
23
|
{% endfor %}
|
|
21
24
|
)
|
|
25
|
+
{% elif has_enums %}
|
|
26
|
+
|
|
27
|
+
from . import _enums
|
|
22
28
|
{% endif %}
|
|
23
29
|
{{ keywords.patch_imports() }}
|
|
24
30
|
__all__ = [
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
{% endfor %}
|
|
20
20
|
{% for description in param_description_and_response_docstring %}
|
|
21
21
|
{% if description %}
|
|
22
|
-
{
|
|
22
|
+
{% set description = wrap_string(description, wrapstring='\n ') %}
|
|
23
|
+
{{ " " if description[0] != ":" and description[0] != " " else "" }}{{ description}}
|
|
23
24
|
{% else %}
|
|
24
25
|
|
|
25
26
|
{% endif %}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "6.41.
|
|
3
|
+
"version": "6.41.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.
|
|
22
|
+
"@typespec/http-client-python": "~0.19.0",
|
|
23
23
|
"@autorest/system-requirements": "~1.0.2",
|
|
24
24
|
"fs-extra": "~11.2.0",
|
|
25
25
|
"tsx": "~4.19.1"
|
|
Binary file
|