@autorest/python 5.12.5 → 5.12.6
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/ChangeLog.md +16 -0
- package/autorest/codegen/models/client.py +6 -5
- package/autorest/codegen/models/lro_operation.py +6 -2
- package/autorest/codegen/models/operation.py +9 -7
- package/autorest/codegen/models/operation_group.py +0 -9
- package/autorest/codegen/models/paging_operation.py +3 -3
- package/autorest/codegen/models/parameter.py +1 -0
- package/autorest/codegen/models/parameter_list.py +1 -0
- package/autorest/codegen/models/request_builder.py +3 -2
- package/autorest/codegen/models/request_builder_parameter_list.py +1 -0
- package/autorest/codegen/serializers/builder_serializer.py +33 -26
- package/autorest/codegen/serializers/client_serializer.py +14 -3
- package/autorest/codegen/serializers/utils.py +5 -1
- package/autorest/codegen/templates/config.py.jinja2 +2 -7
- package/autorest/codegen/templates/lro_operation.py.jinja2 +3 -1
- package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +2 -0
- package/autorest/codegen/templates/operation.py.jinja2 +6 -2
- package/autorest/codegen/templates/operation_group.py.jinja2 +2 -1
- package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -0
- package/autorest/codegen/templates/operation_tools.jinja2 +3 -2
- package/autorest/codegen/templates/paging_operation.py.jinja2 +2 -2
- package/autorest/codegen/templates/request_builder.py.jinja2 +2 -7
- package/autorest/codegen/templates/service_client.py.jinja2 +1 -1
- package/package.json +2 -2
package/ChangeLog.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
### 2022-02-09 - 5.12.6
|
|
4
|
+
|
|
5
|
+
| Library | Min Version
|
|
6
|
+
| --------------- | -------
|
|
7
|
+
|`@autorest/core` | `3.6.2`
|
|
8
|
+
|`@autorest/modelerfour` | `4.19.1`
|
|
9
|
+
|`azure-core` dep of generated code | `1.20.1`
|
|
10
|
+
|`msrest` dep of generated code | `0.6.21`
|
|
11
|
+
|`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
|
|
12
|
+
|
|
13
|
+
**Bug Fixes**
|
|
14
|
+
|
|
15
|
+
- Remove unused `metadata` value for paging and long running operations with `version-tolerant` generations #1131
|
|
16
|
+
- Remove name conflicts with parameters called `url`, `header_parameters`, and `query_parameters` #1143
|
|
17
|
+
- Make `--version-tolerant` generated code pylint compatible in the `azure-sdk-for-python` repo when generated with the `--black` flag #1147, #1144, #1130
|
|
18
|
+
|
|
3
19
|
### 2022-01-26 - 5.12.5
|
|
4
20
|
|
|
5
21
|
| Library | Min Version
|
|
@@ -33,13 +33,14 @@ class Client:
|
|
|
33
33
|
def _imports_shared(self, async_mode: bool) -> FileImport:
|
|
34
34
|
file_import = FileImport()
|
|
35
35
|
|
|
36
|
-
file_import.add_submodule_import("msrest", "Serializer", ImportType.
|
|
37
|
-
file_import.add_submodule_import("msrest", "Deserializer", ImportType.
|
|
36
|
+
file_import.add_submodule_import("msrest", "Serializer", ImportType.THIRDPARTY)
|
|
37
|
+
file_import.add_submodule_import("msrest", "Deserializer", ImportType.THIRDPARTY)
|
|
38
38
|
file_import.add_submodule_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
39
39
|
|
|
40
40
|
any_optional_gp = any(not gp.required for gp in self.parameters)
|
|
41
41
|
|
|
42
|
-
if
|
|
42
|
+
legacy = not any(g for g in ["low_level_client", "version_tolerant"] if g in self.code_model.options)
|
|
43
|
+
if any_optional_gp or (legacy and self.code_model.service_client.parameters.host):
|
|
43
44
|
file_import.add_submodule_import("typing", "Optional", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
44
45
|
|
|
45
46
|
if self.code_model.options["azure_arm"]:
|
|
@@ -98,6 +99,6 @@ class Client:
|
|
|
98
99
|
pass
|
|
99
100
|
return file_import
|
|
100
101
|
|
|
101
|
-
def send_request_signature(self,
|
|
102
|
-
request_signature = ["request: HttpRequest," if
|
|
102
|
+
def send_request_signature(self, is_python3_file: bool) -> List[str]:
|
|
103
|
+
request_signature = ["request: HttpRequest," if is_python3_file else "request, # type: HttpRequest"]
|
|
103
104
|
return request_signature + self.parameters.method_signature_kwargs(is_python3_file)
|
|
@@ -175,6 +175,10 @@ class LROOperation(Operation):
|
|
|
175
175
|
|
|
176
176
|
if async_mode:
|
|
177
177
|
file_import.add_submodule_import("typing", "Optional", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
178
|
-
if self.
|
|
179
|
-
file_import.add_submodule_import(
|
|
178
|
+
if self.code_model.options["tracing"] and self.want_tracing:
|
|
179
|
+
file_import.add_submodule_import(
|
|
180
|
+
f"azure.core.tracing.decorator{'_async' if async_mode else ''}",
|
|
181
|
+
f"distributed_trace{'_async' if async_mode else ''}",
|
|
182
|
+
ImportType.AZURECORE,
|
|
183
|
+
)
|
|
180
184
|
return file_import
|
|
@@ -159,7 +159,8 @@ class Operation(BaseBuilder): # pylint: disable=too-many-public-methods, too-ma
|
|
|
159
159
|
if response.has_body:
|
|
160
160
|
file_import.merge(cast(BaseSchema, response.schema).imports())
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
response_types = [r.operation_type_annotation for r in self.responses if r.has_body]
|
|
163
|
+
if len(set(response_types)) > 1:
|
|
163
164
|
file_import.add_submodule_import("typing", "Union", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
164
165
|
|
|
165
166
|
if self.is_stream_response:
|
|
@@ -179,13 +180,10 @@ class Operation(BaseBuilder): # pylint: disable=too-many-public-methods, too-ma
|
|
|
179
180
|
file_import.add_submodule_import("azure.mgmt.core.exceptions", "ARMErrorFormat", ImportType.AZURECORE)
|
|
180
181
|
file_import.add_submodule_import("azure.core.exceptions", "HttpResponseError", ImportType.AZURECORE)
|
|
181
182
|
|
|
182
|
-
|
|
183
|
-
file_import.add_import("functools", ImportType.STDLIB)
|
|
184
183
|
file_import.add_submodule_import("typing", "Callable", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
185
184
|
file_import.add_submodule_import("typing", "Optional", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
186
185
|
file_import.add_submodule_import("typing", "Dict", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
187
186
|
file_import.add_submodule_import("typing", "TypeVar", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
188
|
-
file_import.add_submodule_import("typing", "Generic", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
189
187
|
file_import.add_submodule_import("azure.core.pipeline", "PipelineResponse", ImportType.AZURECORE)
|
|
190
188
|
file_import.add_submodule_import("azure.core.rest", "HttpRequest", ImportType.AZURECORE)
|
|
191
189
|
if async_mode:
|
|
@@ -193,9 +191,7 @@ class Operation(BaseBuilder): # pylint: disable=too-many-public-methods, too-ma
|
|
|
193
191
|
else:
|
|
194
192
|
file_import.add_submodule_import("azure.core.pipeline.transport", "HttpResponse", ImportType.AZURECORE)
|
|
195
193
|
|
|
196
|
-
|
|
197
|
-
# FIXME: Replace with "the YAML contains deprecated:true"
|
|
198
|
-
if True: # pylint: disable=using-constant-test
|
|
194
|
+
if self.deprecated:
|
|
199
195
|
file_import.add_import("warnings", ImportType.STDLIB)
|
|
200
196
|
|
|
201
197
|
if self.code_model.options["builders_visibility"] != "embedded":
|
|
@@ -227,6 +223,12 @@ class Operation(BaseBuilder): # pylint: disable=too-many-public-methods, too-ma
|
|
|
227
223
|
any(r for r in self.responses if r.has_body)
|
|
228
224
|
):
|
|
229
225
|
file_import.define_mypy_type("JSONType", "Any")
|
|
226
|
+
if self.code_model.options["tracing"] and self.want_tracing:
|
|
227
|
+
file_import.add_submodule_import(
|
|
228
|
+
f"azure.core.tracing.decorator{'_async' if async_mode else ''}",
|
|
229
|
+
f"distributed_trace{'_async' if async_mode else ''}",
|
|
230
|
+
ImportType.AZURECORE,
|
|
231
|
+
)
|
|
230
232
|
return file_import
|
|
231
233
|
|
|
232
234
|
def _get_body_param_from_body_kwarg(self, body_kwarg: Parameter) -> Parameter:
|
|
@@ -63,15 +63,6 @@ class OperationGroup(BaseModel):
|
|
|
63
63
|
file_import.add_submodule_import("azure.core.exceptions", "ResourceExistsError", ImportType.AZURECORE)
|
|
64
64
|
for operation in self.operations:
|
|
65
65
|
file_import.merge(operation.imports(async_mode))
|
|
66
|
-
if self.code_model.options["tracing"]:
|
|
67
|
-
if async_mode:
|
|
68
|
-
file_import.add_submodule_import(
|
|
69
|
-
"azure.core.tracing.decorator_async", "distributed_trace_async", ImportType.AZURECORE,
|
|
70
|
-
)
|
|
71
|
-
else:
|
|
72
|
-
file_import.add_submodule_import(
|
|
73
|
-
"azure.core.tracing.decorator", "distributed_trace", ImportType.AZURECORE,
|
|
74
|
-
)
|
|
75
66
|
local_path = "..." if async_mode else ".."
|
|
76
67
|
if self.code_model.has_schemas and self.code_model.options["models_mode"]:
|
|
77
68
|
file_import.add_submodule_import(local_path, "models", ImportType.LOCAL, alias="_models")
|
|
@@ -147,6 +147,8 @@ class PagingOperation(Operation):
|
|
|
147
147
|
|
|
148
148
|
def imports(self, async_mode: bool) -> FileImport:
|
|
149
149
|
file_import = super(PagingOperation, self).imports(async_mode)
|
|
150
|
+
# operation adds an import for distributed_trace_async, we don't want it
|
|
151
|
+
file_import.imports = [i for i in file_import.imports if not i.submodule_name == "distributed_trace_async"]
|
|
150
152
|
|
|
151
153
|
pager_import_path = ".".join(self.get_pager_path(async_mode).split(".")[:-1])
|
|
152
154
|
pager = self.get_pager(async_mode)
|
|
@@ -156,11 +158,9 @@ class PagingOperation(Operation):
|
|
|
156
158
|
if async_mode:
|
|
157
159
|
file_import.add_submodule_import("azure.core.async_paging", "AsyncList", ImportType.AZURECORE)
|
|
158
160
|
|
|
159
|
-
if self.code_model.options["tracing"]:
|
|
161
|
+
if self.code_model.options["tracing"] and self.want_tracing:
|
|
160
162
|
file_import.add_submodule_import(
|
|
161
163
|
"azure.core.tracing.decorator", "distributed_trace", ImportType.AZURECORE,
|
|
162
164
|
)
|
|
163
|
-
if not self.code_model.options["models_mode"]:
|
|
164
|
-
file_import.add_submodule_import("json", "loads", ImportType.STDLIB, alias="_loads")
|
|
165
165
|
|
|
166
166
|
return file_import
|
|
@@ -98,6 +98,7 @@ class Parameter(BaseModel): # pylint: disable=too-many-instance-attributes, too
|
|
|
98
98
|
self.content_types = content_types or []
|
|
99
99
|
self.body_kwargs: List[Parameter] = []
|
|
100
100
|
self.is_body_kwarg = False
|
|
101
|
+
self.need_import = True
|
|
101
102
|
|
|
102
103
|
def __hash__(self) -> int:
|
|
103
104
|
return hash(self.serialized_name)
|
|
@@ -275,6 +275,7 @@ class ParameterList(MutableSequence): # pylint: disable=too-many-public-methods
|
|
|
275
275
|
def _create_files_or_data_param(
|
|
276
276
|
params: List[Parameter], serialized_name: str, description: str
|
|
277
277
|
) -> Parameter:
|
|
278
|
+
params[0].need_import = False
|
|
278
279
|
param = copy(params[0])
|
|
279
280
|
param.serialized_name = serialized_name
|
|
280
281
|
param.schema = DictionarySchema(
|
|
@@ -66,7 +66,8 @@ class RequestBuilder(BaseBuilder):
|
|
|
66
66
|
def imports(self) -> FileImport:
|
|
67
67
|
file_import = FileImport()
|
|
68
68
|
for parameter in self.parameters:
|
|
69
|
-
|
|
69
|
+
if parameter.need_import:
|
|
70
|
+
file_import.merge(parameter.imports())
|
|
70
71
|
|
|
71
72
|
file_import.add_submodule_import(
|
|
72
73
|
"azure.core.rest",
|
|
@@ -87,7 +88,7 @@ class RequestBuilder(BaseBuilder):
|
|
|
87
88
|
file_import.add_submodule_import(
|
|
88
89
|
"typing", "Any", ImportType.STDLIB, typing_section=TypingSection.CONDITIONAL
|
|
89
90
|
)
|
|
90
|
-
file_import.add_submodule_import("msrest", "Serializer", ImportType.
|
|
91
|
+
file_import.add_submodule_import("msrest", "Serializer", ImportType.THIRDPARTY)
|
|
91
92
|
if self.parameters.has_body and (
|
|
92
93
|
self.code_model.options["builders_visibility"] != "embedded" or
|
|
93
94
|
self.code_model.options["add_python3_operation_files"]
|
|
@@ -33,6 +33,9 @@ from . import utils
|
|
|
33
33
|
T = TypeVar("T")
|
|
34
34
|
OrderedSet = Dict[T, None]
|
|
35
35
|
|
|
36
|
+
def _escape_str(input_str: str) -> str:
|
|
37
|
+
replace = input_str.replace("'", "\\'")
|
|
38
|
+
return f'"{replace}"'
|
|
36
39
|
|
|
37
40
|
def _improve_json_string(template_representation: str) -> Any:
|
|
38
41
|
origin = template_representation.split('\n')
|
|
@@ -110,7 +113,7 @@ def _pop_parameters_kwarg(
|
|
|
110
113
|
function_name: str,
|
|
111
114
|
kwarg_name: str,
|
|
112
115
|
) -> str:
|
|
113
|
-
return f'{function_name}_parameters = kwargs.pop("{kwarg_name}", {{}}) # type: Dict[str, Any]'
|
|
116
|
+
return f'_{function_name}_parameters = kwargs.pop("{kwarg_name}", {{}}) # type: Dict[str, Any]'
|
|
114
117
|
|
|
115
118
|
def _serialize_grouped_body(builder) -> List[str]:
|
|
116
119
|
retval: List[str] = []
|
|
@@ -180,11 +183,6 @@ class _BuilderSerializerProtocol(ABC):
|
|
|
180
183
|
"""Whether you want inline type hints. If false, your type hints will be commented'"""
|
|
181
184
|
...
|
|
182
185
|
|
|
183
|
-
@abstractmethod
|
|
184
|
-
def _method_signature(self, builder) -> str:
|
|
185
|
-
"""Signature of the builder. Does not include return type annotation"""
|
|
186
|
-
...
|
|
187
|
-
|
|
188
186
|
@abstractmethod
|
|
189
187
|
def _response_type_annotation(self, builder, modify_if_head_as_boolean: bool = True) -> str:
|
|
190
188
|
"""The mypy type annotation for the response"""
|
|
@@ -266,20 +264,22 @@ class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abs
|
|
|
266
264
|
def _cls_docstring_rtype(self) -> str:
|
|
267
265
|
return "" if self.code_model.options["version_tolerant"] else " or the result of cls(response)"
|
|
268
266
|
|
|
269
|
-
def _method_signature(self, builder) -> str:
|
|
267
|
+
def _method_signature(self, builder: Operation, response_type_annotation: str) -> str:
|
|
270
268
|
return utils.serialize_method(
|
|
271
269
|
function_def=self._function_definition,
|
|
272
270
|
method_name=builder.name,
|
|
273
271
|
is_in_class=self._is_in_class,
|
|
274
272
|
method_param_signatures=builder.parameters.method_signature(self._want_inline_type_hints),
|
|
273
|
+
ignore_inconsistent_return_statements=(response_type_annotation == "None")
|
|
275
274
|
)
|
|
276
275
|
|
|
277
276
|
def _response_type_annotation_wrapper(self, builder) -> List[str]:
|
|
278
277
|
return []
|
|
279
278
|
|
|
280
279
|
def method_signature_and_response_type_annotation(self, builder) -> str:
|
|
281
|
-
method_signature = self._method_signature(builder)
|
|
282
280
|
response_type_annotation = self._response_type_annotation(builder)
|
|
281
|
+
# want pre-wrapped response type. As long as it's None, pylint will get mad about inconsistent return types
|
|
282
|
+
method_signature = self._method_signature(builder, response_type_annotation)
|
|
283
283
|
for wrapper in self._response_type_annotation_wrapper(builder)[::-1]:
|
|
284
284
|
response_type_annotation = f"{wrapper}[{response_type_annotation}]"
|
|
285
285
|
return self._method_signature_and_response_type_annotation_template(method_signature, response_type_annotation)
|
|
@@ -402,7 +402,7 @@ class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abs
|
|
|
402
402
|
def _serialize_parameter(
|
|
403
403
|
self, param: Parameter, function_name: str
|
|
404
404
|
) -> List[str]:
|
|
405
|
-
set_parameter = "{}_parameters['{}'] = {}".format(
|
|
405
|
+
set_parameter = "_{}_parameters['{}'] = {}".format(
|
|
406
406
|
function_name,
|
|
407
407
|
param.rest_api_name,
|
|
408
408
|
utils.build_serialize_data_call(param, function_name, self.serializer_name)
|
|
@@ -499,11 +499,11 @@ class _RequestBuilderBaseSerializer(_BuilderBaseSerializer): # pylint: disable=
|
|
|
499
499
|
def create_http_request(self, builder) -> List[str]:
|
|
500
500
|
retval = ["return HttpRequest("]
|
|
501
501
|
retval.append(f' method="{builder.method}",')
|
|
502
|
-
retval.append(" url=
|
|
502
|
+
retval.append(" url=_url,")
|
|
503
503
|
if builder.parameters.query:
|
|
504
|
-
retval.append(" params=
|
|
504
|
+
retval.append(" params=_query_parameters,")
|
|
505
505
|
if builder.parameters.headers:
|
|
506
|
-
retval.append(" headers=
|
|
506
|
+
retval.append(" headers=_header_parameters,")
|
|
507
507
|
if builder.parameters.has_body:
|
|
508
508
|
retval.extend([
|
|
509
509
|
f" {body_kwarg}={body_kwarg},"
|
|
@@ -533,6 +533,13 @@ class _RequestBuilderBaseSerializer(_BuilderBaseSerializer): # pylint: disable=
|
|
|
533
533
|
))
|
|
534
534
|
return retval
|
|
535
535
|
|
|
536
|
+
def construct_url(self, builder) -> str:
|
|
537
|
+
if any(o for o in ["low_level_client", "version_tolerant"] if self.code_model.options.get(o)):
|
|
538
|
+
url_value = _escape_str(builder.url)
|
|
539
|
+
else:
|
|
540
|
+
url_value = f'kwargs.pop("template_url", {_escape_str(builder.url)})'
|
|
541
|
+
return f"_url = {url_value}{' # pylint: disable=line-too-long' if len(url_value) > 114 else ''}"
|
|
542
|
+
|
|
536
543
|
class RequestBuilderGenericSerializer(_RequestBuilderBaseSerializer):
|
|
537
544
|
@property
|
|
538
545
|
def _want_inline_type_hints(self) -> bool:
|
|
@@ -711,7 +718,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
|
|
|
711
718
|
)
|
|
712
719
|
ser_ctxt_name = "serialization_ctxt"
|
|
713
720
|
ser_ctxt = builder.parameters.body[0].xml_serialization_ctxt if send_xml else None
|
|
714
|
-
if ser_ctxt:
|
|
721
|
+
if ser_ctxt and self.code_model.options["models_mode"]:
|
|
715
722
|
retval.append(f'{ser_ctxt_name} = {{"xml": {{{ser_ctxt}}}}}')
|
|
716
723
|
serialize_body_call = self._serialize_body_call(
|
|
717
724
|
builder,
|
|
@@ -986,7 +993,8 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
|
|
|
986
993
|
|
|
987
994
|
@staticmethod
|
|
988
995
|
def get_metadata_url(builder) -> str:
|
|
989
|
-
|
|
996
|
+
url = _escape_str(builder.request_builder.url)
|
|
997
|
+
return f"{builder.python_name}.metadata = {{'url': { url }}} # type: ignore"
|
|
990
998
|
|
|
991
999
|
class _SyncOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=abstract-method
|
|
992
1000
|
@property
|
|
@@ -1114,7 +1122,7 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
|
|
|
1114
1122
|
deserialized = (
|
|
1115
1123
|
f'self._deserialize("{response.serialization_type}", pipeline_response)'
|
|
1116
1124
|
if self.code_model.options["models_mode"] else
|
|
1117
|
-
"
|
|
1125
|
+
"pipeline_response.http_response.json()"
|
|
1118
1126
|
)
|
|
1119
1127
|
retval.append(f" deserialized = {deserialized}")
|
|
1120
1128
|
item_name = builder.item_name(self.code_model)
|
|
@@ -1137,10 +1145,11 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
|
|
|
1137
1145
|
retval = [f"{self._def} get_next(next_link=None):"]
|
|
1138
1146
|
retval.append(" request = prepare_request(next_link)")
|
|
1139
1147
|
retval.append("")
|
|
1140
|
-
retval.append(
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
)
|
|
1148
|
+
retval.append(f" pipeline_response = {self._call_method}self._client._pipeline.run( # pylint: disable=protected-access")
|
|
1149
|
+
retval.append(" request,")
|
|
1150
|
+
retval.append(f" stream={builder.is_stream_response},")
|
|
1151
|
+
retval.append(" **kwargs")
|
|
1152
|
+
retval.append(" )")
|
|
1144
1153
|
retval.append(" response = pipeline_response.http_response")
|
|
1145
1154
|
retval.append("")
|
|
1146
1155
|
retval.extend([
|
|
@@ -1234,7 +1243,7 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
|
|
|
1234
1243
|
"Pass in False for this operation to not poll, or pass in your own initialized polling object for a"
|
|
1235
1244
|
" personal polling strategy."
|
|
1236
1245
|
)
|
|
1237
|
-
retval.append(f":paramtype polling: bool or ~{self._polling_method_type}")
|
|
1246
|
+
retval.append(f":paramtype polling: bool or ~azure.core.polling.{self._polling_method_type}")
|
|
1238
1247
|
retval.append(
|
|
1239
1248
|
":keyword int polling_interval: Default waiting time between two polls for LRO operations "
|
|
1240
1249
|
"if no Retry-After header is present."
|
|
@@ -1287,9 +1296,8 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
|
|
|
1287
1296
|
retval.append(" client=self._client,")
|
|
1288
1297
|
retval.append(" deserialization_callback=get_long_running_output")
|
|
1289
1298
|
retval.append(" )")
|
|
1290
|
-
retval.append("else:")
|
|
1291
1299
|
retval.append(
|
|
1292
|
-
f"
|
|
1300
|
+
f"return {self._poller(builder)}"
|
|
1293
1301
|
"(self._client, raw_result, get_long_running_output, polling_method)"
|
|
1294
1302
|
)
|
|
1295
1303
|
return retval
|
|
@@ -1335,7 +1343,7 @@ class _SyncLROOperationBaseSerializer(_LROOperationBaseSerializer, _SyncOperatio
|
|
|
1335
1343
|
|
|
1336
1344
|
@property
|
|
1337
1345
|
def _polling_method_type(self):
|
|
1338
|
-
return "
|
|
1346
|
+
return "PollingMethod"
|
|
1339
1347
|
|
|
1340
1348
|
def _poller(self, builder) -> str:
|
|
1341
1349
|
return builder.get_poller(async_mode=False)
|
|
@@ -1368,7 +1376,7 @@ class AsyncLROOperationSerializer(_LROOperationBaseSerializer, AsyncOperationSer
|
|
|
1368
1376
|
|
|
1369
1377
|
@property
|
|
1370
1378
|
def _polling_method_type(self):
|
|
1371
|
-
return "
|
|
1379
|
+
return "AsyncPollingMethod"
|
|
1372
1380
|
|
|
1373
1381
|
def _poller(self, builder) -> str:
|
|
1374
1382
|
return builder.get_poller(async_mode=True)
|
|
@@ -1383,8 +1391,7 @@ class _LROPagingOperationBaseSerializer(_LROOperationBaseSerializer, _PagingOper
|
|
|
1383
1391
|
retval.append(f" {self._def} internal_get_next(next_link=None):")
|
|
1384
1392
|
retval.append(" if next_link is None:")
|
|
1385
1393
|
retval.append(" return pipeline_response")
|
|
1386
|
-
retval.append("
|
|
1387
|
-
retval.append(f" return {self._call_method}get_next(next_link)")
|
|
1394
|
+
retval.append(f" return {self._call_method}get_next(next_link)")
|
|
1388
1395
|
retval.append("")
|
|
1389
1396
|
retval.append(f" return {self._pager(builder)}(")
|
|
1390
1397
|
retval.append(" internal_get_next, extract_data")
|
|
@@ -44,9 +44,12 @@ class ClientSerializer:
|
|
|
44
44
|
base_class = f"{class_name}OperationsMixin"
|
|
45
45
|
elif not (async_mode or self.is_python3_file):
|
|
46
46
|
base_class = "object"
|
|
47
|
+
disable = ""
|
|
48
|
+
if len(self.code_model.operation_groups) > 6:
|
|
49
|
+
disable = " # pylint: disable=too-many-instance-attributes"
|
|
47
50
|
if base_class:
|
|
48
|
-
return f"class {class_name}({base_class}):"
|
|
49
|
-
return f"class {class_name}:"
|
|
51
|
+
return f"class {class_name}({base_class}):{disable}"
|
|
52
|
+
return f"class {class_name}:{disable}"
|
|
50
53
|
|
|
51
54
|
def property_descriptions(self, async_mode: bool) -> List[str]:
|
|
52
55
|
retval: List[str] = []
|
|
@@ -113,7 +116,7 @@ class ClientSerializer:
|
|
|
113
116
|
method_name=self.code_model.send_request_name,
|
|
114
117
|
is_in_class=True,
|
|
115
118
|
method_param_signatures=self.code_model.service_client.send_request_signature(
|
|
116
|
-
async_mode
|
|
119
|
+
async_mode or self.is_python3_file
|
|
117
120
|
),
|
|
118
121
|
)
|
|
119
122
|
|
|
@@ -227,3 +230,11 @@ class ConfigSerializer:
|
|
|
227
230
|
for p in self.code_model.global_parameters.config_method
|
|
228
231
|
if p.required and not p.constant
|
|
229
232
|
]
|
|
233
|
+
|
|
234
|
+
def property_descriptions(self) -> List[str]:
|
|
235
|
+
retval: List[str] = []
|
|
236
|
+
for p in self.code_model.global_parameters.config_method:
|
|
237
|
+
retval.append(f":{p.description_keyword} {p.serialized_name}: {p.description}")
|
|
238
|
+
retval.append(f":{p.docstring_type_keyword} {p.serialized_name}: {p.docstring_type}")
|
|
239
|
+
retval.append('"""')
|
|
240
|
+
return retval
|
|
@@ -13,9 +13,13 @@ def serialize_method(
|
|
|
13
13
|
method_name: str,
|
|
14
14
|
is_in_class: bool,
|
|
15
15
|
method_param_signatures: List[str],
|
|
16
|
+
ignore_inconsistent_return_statements: bool = False,
|
|
16
17
|
):
|
|
17
18
|
lines: List[str] = []
|
|
18
|
-
|
|
19
|
+
first_line = f"{function_def} {method_name}("
|
|
20
|
+
if ignore_inconsistent_return_statements:
|
|
21
|
+
first_line += " # pylint: disable=inconsistent-return-statements"
|
|
22
|
+
lines.append(first_line)
|
|
19
23
|
if is_in_class:
|
|
20
24
|
lines.append(" self,")
|
|
21
25
|
lines.extend([
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
VERSION = "unknown"
|
|
12
12
|
{% endif %}
|
|
13
13
|
|
|
14
|
-
class {{ code_model.class_name }}Configuration(Configuration):
|
|
14
|
+
class {{ code_model.class_name }}Configuration(Configuration): # pylint: disable=too-many-instance-attributes
|
|
15
15
|
"""Configuration for {{ code_model.class_name }}.
|
|
16
16
|
|
|
17
17
|
Note that all parameters used to create this instance are saved as instance
|
|
@@ -19,12 +19,7 @@ class {{ code_model.class_name }}Configuration(Configuration):
|
|
|
19
19
|
{% if code_model.global_parameters.config_method | first %}
|
|
20
20
|
|
|
21
21
|
{% endif %}
|
|
22
|
-
{
|
|
23
|
-
:{{ parameter.description_keyword }} {{ parameter.serialized_name }}: {{ parameter.description }}
|
|
24
|
-
:{{ parameter.docstring_type_keyword }} {{ parameter.serialized_name }}: {{ parameter.docstring_type }}
|
|
25
|
-
{% endfor %}
|
|
26
|
-
"""
|
|
27
|
-
|
|
22
|
+
{{ op_tools.serialize_with_wrap(serializer.property_descriptions(), "\n ") | indent }}
|
|
28
23
|
{{ serializer.init_signature_and_response_type_annotation(async_mode) | indent }}
|
|
29
24
|
super({{ code_model.class_name }}Configuration, self).__init__(**kwargs)
|
|
30
25
|
{% if code_model.service_client.parameters.config_kwargs_to_pop(async_mode) %}
|
|
@@ -13,4 +13,6 @@
|
|
|
13
13
|
{{ op_tools.serialize(operation_serializer.get_long_running_output(operation)) | indent }}
|
|
14
14
|
|
|
15
15
|
{{ op_tools.serialize(operation_serializer.return_lro_poller(operation)) | indent }}
|
|
16
|
-
{
|
|
16
|
+
{% if not code_model.options["version_tolerant"] %}
|
|
17
|
+
{{ operation_serializer.get_metadata_url(operation) -}}
|
|
18
|
+
{% endif %}
|
|
@@ -15,4 +15,6 @@
|
|
|
15
15
|
{{ op_tools.serialize(operation_serializer.initial_call(operation)) | indent }}
|
|
16
16
|
{{ op_tools.serialize(operation_serializer.get_long_running_output(operation)) | indent }}
|
|
17
17
|
{{ op_tools.serialize(operation_serializer.return_lro_poller(operation)) | indent }}
|
|
18
|
+
{% if not code_model.options["version_tolerant"] %}
|
|
18
19
|
{{ operation_serializer.get_metadata_url(operation) }}
|
|
20
|
+
{% endif %}
|
|
@@ -18,8 +18,12 @@
|
|
|
18
18
|
{{ op_tools.serialize(operation_serializer.pop_kwargs_from_signature(operation)) | indent }}
|
|
19
19
|
{% endif %}
|
|
20
20
|
{{ op_tools.serialize(operation_serializer.call_request_builder(operation)) | indent }}
|
|
21
|
-
pipeline_response = {{ keywords.await }}self._client._pipeline.run(
|
|
21
|
+
pipeline_response = {{ keywords.await }}self._client._pipeline.run( # pylint: disable=protected-access
|
|
22
|
+
request,
|
|
23
|
+
{{ stream_request_parameter }},
|
|
24
|
+
**kwargs
|
|
25
|
+
)
|
|
22
26
|
{{ op_tools.serialize(operation_serializer.handle_response(operation)) | indent }}
|
|
23
27
|
{% if not code_model.options["version_tolerant"] %}
|
|
24
|
-
{{
|
|
28
|
+
{{ operation_serializer.get_metadata_url(operation) }}
|
|
25
29
|
{% endif %}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
{% set disable = " # pylint: disable=too-many-public-methods" if operation_group.operations | length > 20 else "" %}
|
|
2
|
+
class {{ operation_group.class_name }}{{ object_base_class }}:{{ disable }}
|
|
2
3
|
{% if not operation_group.is_empty_operation_group %}
|
|
3
4
|
"""{{ operation_group.class_name }} {{ operations_description }}.
|
|
4
5
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
{% set object_base_class = "" if async_mode else "(object)" %}
|
|
3
3
|
{% set operations_description = "async operations" if async_mode else "operations" %}
|
|
4
4
|
{% set return_none_type_annotation = " -> None" if async_mode else "" %}
|
|
5
|
+
# pylint: disable=too-many-lines
|
|
5
6
|
# coding=utf-8
|
|
6
7
|
{{ code_model.options['license_header'] }}
|
|
7
8
|
{{ imports }}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{% macro wrap_string(string, wrapstring) %}{{ string | wordwrap(width=
|
|
1
|
+
{% macro wrap_string(string, wrapstring, width=95) %}{{ string | wordwrap(width=width, break_long_words=False, break_on_hyphens=False, wrapstring=wrapstring)}}{% endmacro %}
|
|
2
2
|
|
|
3
3
|
{% macro description(builder, serializer) %}
|
|
4
4
|
{% for description in serializer.description_and_summary(builder) %}
|
|
@@ -22,7 +22,8 @@ Example:
|
|
|
22
22
|
.. code-block:: python
|
|
23
23
|
{% for template_line in serializer.get_example_template(builder) %}
|
|
24
24
|
{% if template_line %}
|
|
25
|
-
|
|
25
|
+
{% set wrap_amount = (template_line | length) - (template_line.lstrip() | length) + 10 %}
|
|
26
|
+
{{ wrap_string(template_line, wrapstring='\n' + " " * wrap_amount, width=(95 - wrap_amount)) }}
|
|
26
27
|
{% else %}
|
|
27
28
|
|
|
28
29
|
{% endif %}
|
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
return {{ operation.get_pager(async_mode) }}(
|
|
18
18
|
get_next, extract_data
|
|
19
19
|
)
|
|
20
|
-
{% if not code_model.options["
|
|
21
|
-
{{
|
|
20
|
+
{% if not code_model.options["version_tolerant"] %}
|
|
21
|
+
{{ operation_serializer.get_metadata_url(operation) -}}
|
|
22
22
|
{% endif %}
|
|
@@ -13,15 +13,10 @@
|
|
|
13
13
|
{% endfor %}
|
|
14
14
|
{% endif %}
|
|
15
15
|
# Construct URL
|
|
16
|
-
{
|
|
17
|
-
{% set url_value = keywords.escape_str(request_builder.url) %}
|
|
18
|
-
{% else %}
|
|
19
|
-
{% set url_value = 'kwargs.pop("template_url", ' + keywords.escape_str(request_builder.url) + ')' %}
|
|
20
|
-
{% endif %}
|
|
21
|
-
url = {{ url_value }}
|
|
16
|
+
{{ request_builder_serializer.construct_url(request_builder) }}
|
|
22
17
|
{% if request_builder.parameters.path %}
|
|
23
18
|
{{ op_tools.serialize(request_builder_serializer.serialize_path(request_builder)) | indent }}
|
|
24
|
-
|
|
19
|
+
_url = _format_url_section(_url, **path_format_arguments)
|
|
25
20
|
{% endif %}
|
|
26
21
|
|
|
27
22
|
{% if request_builder.parameters.query %}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
{{ imports }}
|
|
8
8
|
|
|
9
9
|
{{ serializer.class_definition(async_mode) }}
|
|
10
|
-
"""{{ code_model.description }}
|
|
10
|
+
"""{{ op_tools.wrap_string(code_model.description, "\n") | indent }}
|
|
11
11
|
|
|
12
12
|
{{ op_tools.serialize_with_wrap(serializer.property_descriptions(async_mode), "\n ") | indent }}
|
|
13
13
|
{{ serializer.init_signature_and_response_type_annotation(async_mode) | indent }}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.6",
|
|
4
4
|
"description": "The Python extension for generators in AutoRest.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "node run-python3.js prepare.py",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@azure-tools/extension": "~3.2.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@microsoft.azure/autorest.testserver": "^3.1.
|
|
30
|
+
"@microsoft.azure/autorest.testserver": "^3.1.13"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"autorest/**/*.py",
|