@autorest/python 5.12.0 → 5.12.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/ChangeLog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ### 2022-01-10 - 5.12.1
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
+ - Fix support for json merge patch #1117
16
+
3
17
  ### 2021-12-06 - 5.12.0
4
18
 
5
19
  | Library | Min Version
@@ -3,7 +3,7 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
- from typing import Any, Dict, TypeVar, Union
6
+ from typing import Any, Dict
7
7
  from .base_model import BaseModel
8
8
  from .code_model import CodeModel
9
9
  from .credential_schema import AzureKeyCredentialSchema, TokenCredentialSchema
@@ -22,8 +22,7 @@ from .operation import Operation
22
22
  from .property import Property
23
23
  from .operation_group import OperationGroup
24
24
  from .schema_response import SchemaResponse
25
- from .parameter_list import GlobalParameterList, ParameterList
26
- from .request_builder_parameter_list import RequestBuilderParameterList
25
+ from .parameter_list import ParameterList, GlobalParameterList
27
26
  from .request_builder import RequestBuilder
28
27
  from .base_builder import BaseBuilder
29
28
  from .lro_paging_operation import LROPagingOperation
@@ -63,6 +62,7 @@ __all__ = [
63
62
  "HiddenModelObjectSchema",
64
63
  "ParameterStyle",
65
64
  "IOSchema",
65
+ "GlobalParameterList",
66
66
  ]
67
67
 
68
68
  def _generate_as_object_schema(yaml_data: Dict[str, Any]) -> bool:
@@ -119,23 +119,3 @@ def build_schema(yaml_data: Dict[str, Any], **kwargs) -> BaseSchema:
119
119
  code_model.primitives[yaml_id] = schema
120
120
 
121
121
  return schema
122
-
123
- BuilderType = TypeVar(
124
- "BuilderType",
125
- bound=Union[
126
- RequestBuilder,
127
- Operation,
128
- LROPagingOperation,
129
- LROOperation,
130
- PagingOperation,
131
- ]
132
- )
133
-
134
- ParameterListType = TypeVar(
135
- "ParameterListType",
136
- bound=Union[
137
- ParameterList,
138
- GlobalParameterList,
139
- RequestBuilderParameterList,
140
- ],
141
- )
@@ -3,14 +3,11 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
- from typing import Any, Callable, Dict, List, Optional, Union, TYPE_CHECKING
6
+ from typing import Any, Callable, Dict, List, Optional, Union
7
7
  from .base_model import BaseModel
8
8
  from .schema_response import SchemaResponse
9
9
  from .schema_request import SchemaRequest
10
10
 
11
- if TYPE_CHECKING:
12
- from . import ParameterListType
13
-
14
11
 
15
12
  _M4_HEADER_PARAMETERS = ["content_type", "accept"]
16
13
 
@@ -70,7 +67,7 @@ class BaseBuilder(BaseModel):
70
67
  yaml_data: Dict[str, Any],
71
68
  name: str,
72
69
  description: str,
73
- parameters: "ParameterListType",
70
+ parameters,
74
71
  schema_requests: List[SchemaRequest],
75
72
  responses: Optional[List[SchemaResponse]] = None,
76
73
  summary: Optional[str] = None,
@@ -12,6 +12,7 @@ from .parameter import Parameter, ParameterLocation
12
12
  from .base_schema import BaseSchema
13
13
  from .dictionary_schema import DictionarySchema
14
14
  from .primitive_schemas import AnySchema, StringSchema
15
+ from .utils import JSON_REGEXP
15
16
 
16
17
  if TYPE_CHECKING:
17
18
  from .schema_request import SchemaRequest
@@ -79,7 +80,7 @@ class ParameterList(MutableSequence): # pylint: disable=too-many-public-methods
79
80
 
80
81
  @property
81
82
  def default_content_type(self) -> str:
82
- json_content_types = [c for c in self.content_types if "json" in c]
83
+ json_content_types = [c for c in self.content_types if JSON_REGEXP.match(c)]
83
84
  if json_content_types:
84
85
  if "application/json" in json_content_types:
85
86
  return "application/json"
@@ -3,7 +3,6 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
- import re
7
6
  from copy import copy
8
7
  from typing import List, Optional, Tuple, TypeVar, Dict
9
8
  from .request_builder_parameter import RequestBuilderParameter
@@ -13,12 +12,11 @@ from .primitive_schemas import AnySchema, JSONSchema
13
12
  from .dictionary_schema import DictionarySchema
14
13
  from .base_schema import BaseSchema
15
14
  from .schema_request import SchemaRequest
15
+ from .utils import JSON_REGEXP
16
16
 
17
17
  T = TypeVar('T')
18
18
  OrderedSet = Dict[T, None]
19
19
 
20
- _REQUEST_BUILDER_BODY_NAMES = ["files", "json", "content", "data"]
21
- _JSON_REGEXP = re.compile(r'^(application|text)/([0-9a-z+.]+\+)?json$')
22
20
 
23
21
  def _update_content_types(content_types_to_assign: List[str], param: Parameter):
24
22
  return [
@@ -60,7 +58,7 @@ class RequestBuilderParameterList(ParameterList):
60
58
  if sr.yaml_data.get("protocol", {}).get('http', {}).get('knownMediaType') == "json"
61
59
  ):
62
60
  return True
63
- return any(c for c in self.content_types if _JSON_REGEXP.match(c))
61
+ return any(c for c in self.content_types if JSON_REGEXP.match(c))
64
62
 
65
63
  @property
66
64
  def body_kwargs_to_get(self) -> List[Parameter]:
@@ -139,7 +137,7 @@ class RequestBuilderParameterList(ParameterList):
139
137
  json_kwarg.schema = JSONSchema(namespace="", yaml_data={})
140
138
  json_kwarg.content_types = [
141
139
  c for c in content_types_to_assign
142
- if _JSON_REGEXP.match(c)
140
+ if JSON_REGEXP.match(c)
143
141
  ]
144
142
  content_types_to_assign = _update_content_types(content_types_to_assign, json_kwarg)
145
143
  return content_types_to_assign, json_kwarg
@@ -0,0 +1,8 @@
1
+ # -------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # Licensed under the MIT License. See License.txt in the project root for
4
+ # license information.
5
+ # --------------------------------------------------------------------------
6
+ import re
7
+
8
+ JSON_REGEXP = re.compile(r'^(application|text)/(.+\+)?json$')
@@ -16,7 +16,6 @@ from ..models import (
16
16
  PagingOperation,
17
17
  LROOperation,
18
18
  LROPagingOperation,
19
- BuilderType,
20
19
  ObjectSchema,
21
20
  DictionarySchema,
22
21
  ListSchema,
@@ -65,7 +64,7 @@ def _serialize_files_or_data_dict(multipart_parameters: List[Parameter]) -> str:
65
64
  }
66
65
  return _json_dumps_template(template)
67
66
 
68
- def _get_files_example_template(builder: BuilderType) -> List[str]:
67
+ def _get_files_example_template(builder) -> List[str]:
69
68
  multipart_params = builder.parameters.multipart
70
69
  if multipart_params:
71
70
  retval = [
@@ -77,7 +76,7 @@ def _get_files_example_template(builder: BuilderType) -> List[str]:
77
76
  "You're trying to get a template for your multipart params, but you don't have multipart params"
78
77
  )
79
78
 
80
- def _get_data_example_template(builder: BuilderType) -> List[str]:
79
+ def _get_data_example_template(builder) -> List[str]:
81
80
  data_inputs = builder.parameters.data_inputs
82
81
  if data_inputs:
83
82
  retval = [
@@ -89,7 +88,7 @@ def _get_data_example_template(builder: BuilderType) -> List[str]:
89
88
  "You're trying to get a template for your form-encoded params, but you don't have form-encoded params"
90
89
  )
91
90
 
92
- def _content_type_error_check(builder: BuilderType) -> List[str]:
91
+ def _content_type_error_check(builder) -> List[str]:
93
92
  retval = ["else:"]
94
93
  retval.append(" raise ValueError(")
95
94
  retval.append(" \"The content_type '{}' is not one of the allowed values: \"")
@@ -97,7 +96,7 @@ def _content_type_error_check(builder: BuilderType) -> List[str]:
97
96
  retval.append(" )")
98
97
  return retval
99
98
 
100
- def _serialize_files_and_data_body(builder: BuilderType, param_name: str) -> List[str]:
99
+ def _serialize_files_and_data_body(builder, param_name: str) -> List[str]:
101
100
  retval: List[str] = []
102
101
  # we have to construct our form data before passing to the request as well
103
102
  retval.append("# Construct form data")
@@ -113,7 +112,7 @@ def _pop_parameters_kwarg(
113
112
  ) -> str:
114
113
  return f'{function_name}_parameters = kwargs.pop("{kwarg_name}", {{}}) # type: Dict[str, Any]'
115
114
 
116
- def _serialize_grouped_body(builder: BuilderType) -> List[str]:
115
+ def _serialize_grouped_body(builder) -> List[str]:
117
116
  retval: List[str] = []
118
117
  for grouped_parameter in builder.parameters.grouped:
119
118
  retval.append(f"{grouped_parameter.serialized_name} = None")
@@ -128,7 +127,7 @@ def _serialize_grouped_body(builder: BuilderType) -> List[str]:
128
127
  )
129
128
  return retval
130
129
 
131
- def _serialize_flattened_body(builder: BuilderType) -> List[str]:
130
+ def _serialize_flattened_body(builder) -> List[str]:
132
131
  retval: List[str] = []
133
132
  if not builder.parameters.is_flattened:
134
133
  raise ValueError(
@@ -149,7 +148,7 @@ def _serialize_flattened_body(builder: BuilderType) -> List[str]:
149
148
  )
150
149
  return retval
151
150
 
152
- def _content_type_docstring(builder: BuilderType) -> str:
151
+ def _content_type_docstring(builder) -> str:
153
152
  content_type_str = (
154
153
  ":keyword str content_type: Media type of the body sent to the API. " +
155
154
  f'Default value is "{builder.parameters.default_content_type}". ' +
@@ -182,17 +181,17 @@ class _BuilderSerializerProtocol(ABC):
182
181
  ...
183
182
 
184
183
  @abstractmethod
185
- def _method_signature(self, builder: BuilderType) -> str:
184
+ def _method_signature(self, builder) -> str:
186
185
  """Signature of the builder. Does not include return type annotation"""
187
186
  ...
188
187
 
189
188
  @abstractmethod
190
- def _response_type_annotation(self, builder: BuilderType, modify_if_head_as_boolean: bool = True) -> str:
189
+ def _response_type_annotation(self, builder, modify_if_head_as_boolean: bool = True) -> str:
191
190
  """The mypy type annotation for the response"""
192
191
  ...
193
192
 
194
193
  @abstractmethod
195
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
194
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
196
195
  """Any wrappers that you want to go around the response type annotation"""
197
196
  ...
198
197
 
@@ -206,57 +205,57 @@ class _BuilderSerializerProtocol(ABC):
206
205
  ...
207
206
 
208
207
  @abstractmethod
209
- def method_signature_and_response_type_annotation(self, builder: BuilderType) -> str:
208
+ def method_signature_and_response_type_annotation(self, builder) -> str:
210
209
  """Combines the method signature + the response type annotation together"""
211
210
  ...
212
211
 
213
212
  @abstractmethod
214
- def description_and_summary(self, builder: BuilderType) -> List[str]:
213
+ def description_and_summary(self, builder) -> List[str]:
215
214
  """Description + summary from the swagger. Will be formatted into the overall operation description"""
216
215
  ...
217
216
 
218
217
  @abstractmethod
219
- def response_docstring(self, builder: BuilderType) -> List[str]:
218
+ def response_docstring(self, builder) -> List[str]:
220
219
  """Response portion of the docstring"""
221
220
  ...
222
221
 
223
222
  @abstractmethod
224
- def want_example_template(self, builder: BuilderType) -> bool:
223
+ def want_example_template(self, builder) -> bool:
225
224
  ...
226
225
 
227
226
  @abstractmethod
228
- def get_example_template(self, builder: BuilderType) -> List[str]:
227
+ def get_example_template(self, builder) -> List[str]:
229
228
  ...
230
229
 
231
230
  @abstractmethod
232
- def _get_json_example_template(self, builder: BuilderType) -> List[str]:
231
+ def _get_json_example_template(self, builder) -> List[str]:
233
232
  ...
234
233
 
235
234
  @abstractmethod
236
- def _has_json_example_template(self, builder: BuilderType) -> bool:
235
+ def _has_json_example_template(self, builder) -> bool:
237
236
  ...
238
237
 
239
238
  @abstractmethod
240
- def _has_files_example_template(self, builder: BuilderType) -> bool:
239
+ def _has_files_example_template(self, builder) -> bool:
241
240
  ...
242
241
  @abstractmethod
243
- def _has_data_example_template(self, builder: BuilderType) -> bool:
242
+ def _has_data_example_template(self, builder) -> bool:
244
243
  ...
245
244
 
246
245
  @abstractmethod
247
- def _json_example_param_name(self, builder: BuilderType) -> str:
246
+ def _json_example_param_name(self, builder) -> str:
248
247
  ...
249
248
 
250
249
  @abstractmethod
251
- def _get_json_response_template(self, builder: BuilderType) -> List[str]:
250
+ def _get_json_response_template(self, builder) -> List[str]:
252
251
  ...
253
252
 
254
253
  @abstractmethod
255
- def _get_json_response_template_to_status_codes(self, builder: BuilderType) -> Dict[str, List[str]]:
254
+ def _get_json_response_template_to_status_codes(self, builder) -> Dict[str, List[str]]:
256
255
  ...
257
256
 
258
257
  @abstractmethod
259
- def _get_kwargs_to_pop(self, builder: BuilderType) -> List[Parameter]:
258
+ def _get_kwargs_to_pop(self, builder) -> List[Parameter]:
260
259
  ...
261
260
 
262
261
  class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abstract-method
@@ -267,7 +266,7 @@ class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abs
267
266
  def _cls_docstring_rtype(self) -> str:
268
267
  return "" if self.code_model.options["version_tolerant"] else " or the result of cls(response)"
269
268
 
270
- def _method_signature(self, builder: BuilderType) -> str:
269
+ def _method_signature(self, builder) -> str:
271
270
  return utils.serialize_method(
272
271
  function_def=self._function_definition,
273
272
  method_name=builder.name,
@@ -275,17 +274,17 @@ class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abs
275
274
  method_param_signatures=builder.parameters.method_signature(self._want_inline_type_hints),
276
275
  )
277
276
 
278
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
277
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
279
278
  return []
280
279
 
281
- def method_signature_and_response_type_annotation(self, builder: BuilderType) -> str:
280
+ def method_signature_and_response_type_annotation(self, builder) -> str:
282
281
  method_signature = self._method_signature(builder)
283
282
  response_type_annotation = self._response_type_annotation(builder)
284
283
  for wrapper in self._response_type_annotation_wrapper(builder)[::-1]:
285
284
  response_type_annotation = f"{wrapper}[{response_type_annotation}]"
286
285
  return self._method_signature_and_response_type_annotation_template(method_signature, response_type_annotation)
287
286
 
288
- def description_and_summary(self, builder: BuilderType) -> List[str]:
287
+ def description_and_summary(self, builder) -> List[str]:
289
288
  description_list: List[str] = []
290
289
  description_list.append(f"{ builder.summary.strip() if builder.summary else builder.description.strip() }")
291
290
  if builder.summary and builder.description:
@@ -314,10 +313,10 @@ class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abs
314
313
  description_list.append(_content_type_docstring(builder))
315
314
  return description_list
316
315
 
317
- def param_description_and_response_docstring(self, builder: BuilderType) -> List[str]:
316
+ def param_description_and_response_docstring(self, builder) -> List[str]:
318
317
  return self.param_description(builder) + self.response_docstring(builder)
319
318
 
320
- def _get_json_response_template_to_status_codes(self, builder: BuilderType) -> Dict[str, List[str]]:
319
+ def _get_json_response_template_to_status_codes(self, builder) -> Dict[str, List[str]]:
321
320
  # successful status codes of responses that have bodies
322
321
  responses = [
323
322
  response
@@ -338,7 +337,7 @@ class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abs
338
337
  retval[response_json].extend(status_codes)
339
338
  return retval
340
339
 
341
- def get_example_template(self, builder: BuilderType) -> List[str]:
340
+ def get_example_template(self, builder) -> List[str]:
342
341
  template = []
343
342
  if self._has_json_example_template(builder):
344
343
  template.append("")
@@ -354,7 +353,7 @@ class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abs
354
353
  template += self._get_json_response_template(builder)
355
354
  return template
356
355
 
357
- def _get_json_example_template(self, builder: BuilderType) -> List[str]:
356
+ def _get_json_example_template(self, builder) -> List[str]:
358
357
  template = []
359
358
  json_body = builder.parameters.json_body
360
359
  object_schema = cast(ObjectSchema, json_body)
@@ -417,7 +416,7 @@ class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abs
417
416
  ]
418
417
  return retval
419
418
 
420
- def _get_json_response_template(self, builder: BuilderType) -> List[str]:
419
+ def _get_json_response_template(self, builder) -> List[str]:
421
420
  template = []
422
421
  for response_body, status_codes in self._get_json_response_template_to_status_codes(builder).items():
423
422
  template.append("# response body for status code(s): {}".format(", ".join(status_codes)))
@@ -425,10 +424,10 @@ class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abs
425
424
  return template
426
425
 
427
426
 
428
- def pop_kwargs_from_signature(self, builder: BuilderType) -> List[str]:
427
+ def pop_kwargs_from_signature(self, builder) -> List[str]:
429
428
  return utils.pop_kwargs_from_signature(self._get_kwargs_to_pop(builder))
430
429
 
431
- def serialize_path(self, builder: BuilderType) -> List[str]:
430
+ def serialize_path(self, builder) -> List[str]:
432
431
  return utils.serialize_path(builder.parameters.path, self.serializer_name)
433
432
 
434
433
  @property
@@ -440,7 +439,7 @@ class _BuilderBaseSerializer(_BuilderSerializerProtocol): # pylint: disable=abs
440
439
 
441
440
 
442
441
  class _RequestBuilderBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstract-method
443
- def description_and_summary(self, builder: BuilderType) -> List[str]:
442
+ def description_and_summary(self, builder) -> List[str]:
444
443
  retval = super().description_and_summary(builder)
445
444
  retval += [
446
445
  "See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this "
@@ -453,7 +452,7 @@ class _RequestBuilderBaseSerializer(_BuilderBaseSerializer): # pylint: disable=
453
452
  def serializer_name(self) -> str:
454
453
  return "_SERIALIZER"
455
454
 
456
- def want_example_template(self, builder: BuilderType) -> bool:
455
+ def want_example_template(self, builder) -> bool:
457
456
  if self.code_model.options["builders_visibility"] != "public":
458
457
  return False # if we're not exposing rest layer, don't need to generate
459
458
  if builder.parameters.has_body:
@@ -469,10 +468,10 @@ class _RequestBuilderBaseSerializer(_BuilderBaseSerializer): # pylint: disable=
469
468
  def _is_in_class(self) -> bool:
470
469
  return False
471
470
 
472
- def _response_type_annotation(self, builder: BuilderType, modify_if_head_as_boolean: bool = True) -> str:
471
+ def _response_type_annotation(self, builder, modify_if_head_as_boolean: bool = True) -> str:
473
472
  return "HttpRequest"
474
473
 
475
- def response_docstring(self, builder: BuilderType) -> List[str]:
474
+ def response_docstring(self, builder) -> List[str]:
476
475
  response_str = (
477
476
  f":return: Returns an :class:`~azure.core.rest.HttpRequest` that you will pass to the client's "
478
477
  + "`send_request` method. See https://aka.ms/azsdk/python/protocol/quickstart for how to "
@@ -481,23 +480,23 @@ class _RequestBuilderBaseSerializer(_BuilderBaseSerializer): # pylint: disable=
481
480
  rtype_str = f":rtype: ~azure.core.rest.HttpRequest"
482
481
  return [response_str, rtype_str]
483
482
 
484
- def _json_example_param_name(self, builder: BuilderType) -> str:
483
+ def _json_example_param_name(self, builder) -> str:
485
484
  return "json"
486
485
 
487
- def _has_json_example_template(self, builder: BuilderType) -> bool:
486
+ def _has_json_example_template(self, builder) -> bool:
488
487
  return "json" in builder.parameters.body_kwarg_names
489
488
 
490
- def _has_files_example_template(self, builder: BuilderType) -> bool:
489
+ def _has_files_example_template(self, builder) -> bool:
491
490
  return "files" in builder.parameters.body_kwarg_names
492
491
 
493
- def _has_data_example_template(self, builder: BuilderType) -> bool:
492
+ def _has_data_example_template(self, builder) -> bool:
494
493
  return "data" in builder.parameters.body_kwarg_names
495
494
 
496
495
  @abstractmethod
497
- def _body_params_to_pass_to_request_creation(self, builder: BuilderType) -> List[str]:
496
+ def _body_params_to_pass_to_request_creation(self, builder) -> List[str]:
498
497
  ...
499
498
 
500
- def create_http_request(self, builder: BuilderType) -> List[str]:
499
+ def create_http_request(self, builder) -> List[str]:
501
500
  retval = ["return HttpRequest("]
502
501
  retval.append(f' method="{builder.method}",')
503
502
  retval.append(" url=url,")
@@ -514,7 +513,7 @@ class _RequestBuilderBaseSerializer(_BuilderBaseSerializer): # pylint: disable=
514
513
  retval.append(")")
515
514
  return retval
516
515
 
517
- def serialize_headers(self, builder: BuilderType) -> List[str]:
516
+ def serialize_headers(self, builder) -> List[str]:
518
517
  retval = ["# Construct headers"]
519
518
  retval.append(_pop_parameters_kwarg("header", "headers"))
520
519
  for parameter in builder.parameters.headers:
@@ -524,7 +523,7 @@ class _RequestBuilderBaseSerializer(_BuilderBaseSerializer): # pylint: disable=
524
523
  ))
525
524
  return retval
526
525
 
527
- def serialize_query(self, builder: BuilderType) -> List[str]:
526
+ def serialize_query(self, builder) -> List[str]:
528
527
  retval = ["# Construct parameters"]
529
528
  retval.append(_pop_parameters_kwarg("query", "params"))
530
529
  for parameter in builder.parameters.query:
@@ -545,10 +544,10 @@ class RequestBuilderGenericSerializer(_RequestBuilderBaseSerializer):
545
544
  is_python3_file=False, method_signature=method_signature, response_type_annotation=response_type_annotation
546
545
  )
547
546
 
548
- def _get_kwargs_to_pop(self, builder: BuilderType):
547
+ def _get_kwargs_to_pop(self, builder):
549
548
  return builder.parameters.kwargs_to_pop(is_python3_file=False)
550
549
 
551
- def _body_params_to_pass_to_request_creation(self, builder: BuilderType) -> List[str]:
550
+ def _body_params_to_pass_to_request_creation(self, builder) -> List[str]:
552
551
  if builder.parameters.has_body and not builder.parameters.body_kwarg_names:
553
552
  # this means we have a constant body
554
553
  # only doing json body in this case
@@ -567,10 +566,10 @@ class RequestBuilderPython3Serializer(_RequestBuilderBaseSerializer):
567
566
  is_python3_file=True, method_signature=method_signature, response_type_annotation=response_type_annotation
568
567
  )
569
568
 
570
- def _get_kwargs_to_pop(self, builder: BuilderType):
569
+ def _get_kwargs_to_pop(self, builder):
571
570
  return builder.parameters.kwargs_to_pop(is_python3_file=True)
572
571
 
573
- def _body_params_to_pass_to_request_creation(self, builder: BuilderType) -> List[str]:
572
+ def _body_params_to_pass_to_request_creation(self, builder) -> List[str]:
574
573
  body_kwargs = list(builder.parameters.body_kwarg_names.keys())
575
574
  if body_kwargs:
576
575
  return body_kwargs
@@ -585,7 +584,7 @@ class RequestBuilderPython3Serializer(_RequestBuilderBaseSerializer):
585
584
 
586
585
 
587
586
  class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstract-method
588
- def description_and_summary(self, builder: BuilderType) -> List[str]:
587
+ def description_and_summary(self, builder) -> List[str]:
589
588
  retval = super().description_and_summary(builder)
590
589
  if builder.deprecated:
591
590
  retval.append(".. warning::")
@@ -601,10 +600,10 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
601
600
  def serializer_name(self) -> str:
602
601
  return "self._serialize"
603
602
 
604
- def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: # pylint: disable=unused-argument, no-self-use
603
+ def _response_docstring_type_wrapper(self, builder) -> List[str]: # pylint: disable=unused-argument, no-self-use
605
604
  return []
606
605
 
607
- def param_description(self, builder: BuilderType) -> List[str]: # pylint: disable=no-self-use
606
+ def param_description(self, builder) -> List[str]: # pylint: disable=no-self-use
608
607
  description_list = super().param_description(builder)
609
608
  if not self.code_model.options["version_tolerant"]:
610
609
  description_list.append(
@@ -612,13 +611,13 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
612
611
  )
613
612
  return description_list
614
613
 
615
- def _response_docstring_type_template(self, builder: BuilderType) -> str:
614
+ def _response_docstring_type_template(self, builder) -> str:
616
615
  retval = "{}"
617
616
  for wrapper in self._response_docstring_type_wrapper(builder)[::-1]:
618
617
  retval = f"{wrapper}[{retval}]"
619
618
  return retval
620
619
 
621
- def _response_type_annotation(self, builder: BuilderType, modify_if_head_as_boolean: bool = True) -> str:
620
+ def _response_type_annotation(self, builder, modify_if_head_as_boolean: bool = True) -> str:
622
621
  if (
623
622
  modify_if_head_as_boolean
624
623
  and builder.request_builder.method.lower() == "head"
@@ -635,14 +634,14 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
635
634
  response_str = f"Optional[{response_str}]"
636
635
  return response_str
637
636
 
638
- def cls_type_annotation(self, builder: BuilderType) -> str:
637
+ def cls_type_annotation(self, builder) -> str:
639
638
  return f"# type: ClsType[{self._response_type_annotation(builder, modify_if_head_as_boolean=False)}]"
640
639
 
641
- def _response_docstring_text_template(self, builder: BuilderType) -> str: # pylint: disable=no-self-use, unused-argument
640
+ def _response_docstring_text_template(self, builder) -> str: # pylint: disable=no-self-use, unused-argument
642
641
  cls_str = f",{self._cls_docstring_rtype}" if self._cls_docstring_rtype else ""
643
642
  return "{}" + cls_str
644
643
 
645
- def response_docstring(self, builder: BuilderType) -> List[str]:
644
+ def response_docstring(self, builder) -> List[str]:
646
645
  responses_with_body = [r for r in builder.responses if r.has_body]
647
646
  if builder.request_builder.method.lower() == "head" and self.code_model.options["head_as_boolean"]:
648
647
  response_docstring_text = "bool"
@@ -665,7 +664,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
665
664
  rtype_str = f":rtype: {self._response_docstring_type_template(builder).format(rtype)}"
666
665
  return [response_str, rtype_str, ":raises: ~azure.core.exceptions.HttpResponseError"]
667
666
 
668
- def want_example_template(self, builder: BuilderType) -> bool:
667
+ def want_example_template(self, builder) -> bool:
669
668
  if self.code_model.options['models_mode']:
670
669
  return False
671
670
  if builder.parameters.has_body:
@@ -675,23 +674,23 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
675
674
  return any([b for b in body_params if isinstance(b.schema, (DictionarySchema, ListSchema, ObjectSchema))])
676
675
  return bool(self._get_json_response_template_to_status_codes(builder))
677
676
 
678
- def _json_example_param_name(self, builder: BuilderType) -> str:
677
+ def _json_example_param_name(self, builder) -> str:
679
678
  return builder.parameters.body[0].serialized_name
680
679
 
681
- def _has_json_example_template(self, builder: BuilderType) -> bool:
680
+ def _has_json_example_template(self, builder) -> bool:
682
681
  return (
683
682
  builder.parameters.has_body and
684
683
  not (builder.parameters.multipart or builder.parameters.data_inputs)
685
684
  )
686
685
 
687
- def _has_files_example_template(self, builder: BuilderType) -> bool:
686
+ def _has_files_example_template(self, builder) -> bool:
688
687
  return bool(builder.parameters.multipart)
689
688
 
690
- def _has_data_example_template(self, builder: BuilderType) -> bool:
689
+ def _has_data_example_template(self, builder) -> bool:
691
690
  return bool(builder.parameters.data_inputs)
692
691
 
693
692
  def _serialize_body_call(
694
- self, builder: BuilderType, body_param: Parameter, send_xml: bool, ser_ctxt: Optional[str], ser_ctxt_name: str
693
+ self, builder, body_param: Parameter, send_xml: bool, ser_ctxt: Optional[str], ser_ctxt_name: str
695
694
  ) -> str:
696
695
  body_is_xml = ", is_xml=True" if send_xml else ""
697
696
  pass_ser_ctxt = f", {ser_ctxt_name}={ser_ctxt_name}" if ser_ctxt else ""
@@ -703,7 +702,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
703
702
  )
704
703
  return f"_{body_kwarg_to_pass} = {body_param.serialized_name}"
705
704
 
706
- def _serialize_body(self, builder: BuilderType, body_param: Parameter, body_kwarg: str) -> List[str]:
705
+ def _serialize_body(self, builder, body_param: Parameter, body_kwarg: str) -> List[str]:
707
706
  retval = []
708
707
  send_xml = bool(
709
708
  builder.parameters.has_body and
@@ -732,7 +731,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
732
731
  return retval
733
732
 
734
733
  def _set_body_content_kwarg(
735
- self, builder: BuilderType, body_param: Parameter, body_kwarg: Parameter
734
+ self, builder, body_param: Parameter, body_kwarg: Parameter
736
735
  ) -> List[str]:
737
736
  retval: List[str] = []
738
737
  if body_kwarg.serialized_name == "data" or body_kwarg.serialized_name == "files":
@@ -748,7 +747,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
748
747
 
749
748
 
750
749
  def _serialize_body_parameters(
751
- self, builder: BuilderType,
750
+ self, builder,
752
751
  ) -> List[str]:
753
752
  retval = []
754
753
  body_kwargs = [
@@ -779,7 +778,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
779
778
 
780
779
  def _call_request_builder_helper(
781
780
  self,
782
- builder: BuilderType,
781
+ builder,
783
782
  request_builder: RequestBuilder,
784
783
  template_url: Optional[str] = None,
785
784
  ) -> List[str]:
@@ -845,7 +844,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
845
844
  )
846
845
  return retval
847
846
 
848
- def call_request_builder(self, builder: BuilderType) -> List[str]:
847
+ def call_request_builder(self, builder) -> List[str]:
849
848
  return self._call_request_builder_helper(builder, builder.request_builder)
850
849
 
851
850
  def response_headers_and_deserialization(
@@ -886,7 +885,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
886
885
  def _call_method(self) -> str:
887
886
  ...
888
887
 
889
- def handle_error_response(self, builder: BuilderType) -> List[str]:
888
+ def handle_error_response(self, builder) -> List[str]:
890
889
  retval = [f"if response.status_code not in {str(builder.success_status_code)}:"]
891
890
  retval.append(" map_error(status_code=response.status_code, response=response, error_map=error_map)")
892
891
  error_model = ""
@@ -901,7 +900,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
901
900
  ))
902
901
  return retval
903
902
 
904
- def handle_response(self, builder: BuilderType) -> List[str]:
903
+ def handle_response(self, builder) -> List[str]:
905
904
  retval: List[str] = ["response = pipeline_response.http_response"]
906
905
  retval.append("")
907
906
  retval.extend(self.handle_error_response(builder))
@@ -938,7 +937,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
938
937
  retval.append("return 200 <= response.status_code <= 299")
939
938
  return retval
940
939
 
941
- def error_map(self, builder: BuilderType) -> List[str]:
940
+ def error_map(self, builder) -> List[str]:
942
941
  retval = ["error_map = {"]
943
942
  if builder.status_code_exceptions:
944
943
  if not 401 in builder.status_code_exceptions_status_codes:
@@ -986,7 +985,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
986
985
  return retval
987
986
 
988
987
  @staticmethod
989
- def get_metadata_url(builder: BuilderType) -> str:
988
+ def get_metadata_url(builder) -> str:
990
989
  return f"{builder.python_name}.metadata = {{'url': '{ builder.request_builder.url }'}} # type: ignore"
991
990
 
992
991
  class _SyncOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=abstract-method
@@ -1013,7 +1012,7 @@ class SyncOperationGenericSerializer(_SyncOperationBaseSerializer):
1013
1012
  is_python3_file=False, method_signature=method_signature, response_type_annotation=response_type_annotation
1014
1013
  )
1015
1014
 
1016
- def _get_kwargs_to_pop(self, builder: BuilderType):
1015
+ def _get_kwargs_to_pop(self, builder):
1017
1016
  return builder.parameters.kwargs_to_pop(is_python3_file=False)
1018
1017
 
1019
1018
 
@@ -1028,7 +1027,7 @@ class SyncOperationPython3Serializer(_SyncOperationBaseSerializer):
1028
1027
  is_python3_file=True, method_signature=method_signature, response_type_annotation=response_type_annotation
1029
1028
  )
1030
1029
 
1031
- def _get_kwargs_to_pop(self, builder: BuilderType):
1030
+ def _get_kwargs_to_pop(self, builder):
1032
1031
  return builder.parameters.kwargs_to_pop(is_python3_file=True)
1033
1032
 
1034
1033
  class AsyncOperationSerializer(SyncOperationPython3Serializer):
@@ -1050,16 +1049,16 @@ class AsyncOperationSerializer(SyncOperationPython3Serializer):
1050
1049
 
1051
1050
 
1052
1051
  class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=abstract-method
1053
- def _response_docstring_text_template(self, builder: BuilderType) -> str: # pylint: disable=no-self-use, unused-argument
1052
+ def _response_docstring_text_template(self, builder) -> str: # pylint: disable=no-self-use, unused-argument
1054
1053
  if self._cls_docstring_rtype:
1055
1054
  return "An iterator like instance of either {}" + self._cls_docstring_rtype
1056
1055
  return "An iterator like instance of {}"
1057
1056
 
1058
- def cls_type_annotation(self, builder: BuilderType) -> str:
1057
+ def cls_type_annotation(self, builder) -> str:
1059
1058
  interior = super()._response_type_annotation(builder, modify_if_head_as_boolean=False)
1060
1059
  return f"# type: ClsType[{interior}]"
1061
1060
 
1062
- def call_next_link_request_builder(self, builder: BuilderType) -> List[str]:
1061
+ def call_next_link_request_builder(self, builder) -> List[str]:
1063
1062
  if builder.next_request_builder:
1064
1063
  request_builder = builder.next_request_builder
1065
1064
  template_url = None if self.code_model.options["version_tolerant"] else f"'{request_builder.url}'"
@@ -1073,7 +1072,7 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
1073
1072
  template_url=template_url,
1074
1073
  )
1075
1074
 
1076
- def _prepare_request_callback(self, builder: BuilderType) -> List[str]:
1075
+ def _prepare_request_callback(self, builder) -> List[str]:
1077
1076
  retval = ["def prepare_request(next_link=None):"]
1078
1077
  retval.append(" if not next_link:")
1079
1078
  retval.extend([
@@ -1106,10 +1105,10 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
1106
1105
 
1107
1106
  @staticmethod
1108
1107
  @abstractmethod
1109
- def _pager(builder: BuilderType) -> str:
1108
+ def _pager(builder) -> str:
1110
1109
  ...
1111
1110
 
1112
- def _extract_data_callback(self, builder: BuilderType) -> List[str]:
1111
+ def _extract_data_callback(self, builder) -> List[str]:
1113
1112
  retval = [f"{self._def} extract_data(pipeline_response):"]
1114
1113
  response = builder.responses[0]
1115
1114
  deserialized = (
@@ -1134,7 +1133,7 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
1134
1133
  retval.append(f" return {next_link_property}, {self._list_type_returned_to_users}(list_of_elem)")
1135
1134
  return retval
1136
1135
 
1137
- def _get_next_callback(self, builder: BuilderType) -> List[str]:
1136
+ def _get_next_callback(self, builder) -> List[str]:
1138
1137
  retval = [f"{self._def} get_next(next_link=None):"]
1139
1138
  retval.append(" request = prepare_request(next_link)")
1140
1139
  retval.append("")
@@ -1152,7 +1151,7 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
1152
1151
  retval.append(" return pipeline_response")
1153
1152
  return retval
1154
1153
 
1155
- def set_up_params_for_pager(self, builder: BuilderType) -> List[str]:
1154
+ def set_up_params_for_pager(self, builder) -> List[str]:
1156
1155
  retval = [f"cls = kwargs.pop('cls', None) {self.cls_type_annotation(builder)}"]
1157
1156
  retval.extend(self.error_map(builder))
1158
1157
  retval.extend(self._prepare_request_callback(builder))
@@ -1163,10 +1162,10 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
1163
1162
  return retval
1164
1163
 
1165
1164
  class _SyncPagingOperationBaseSerializer(_PagingOperationBaseSerializer, _SyncOperationBaseSerializer): # pylint: disable=abstract-method
1166
- def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: # pylint: no-self-use
1165
+ def _response_docstring_type_wrapper(self, builder) -> List[str]: # pylint: no-self-use
1167
1166
  return [f"~{builder.get_pager_path(async_mode=False)}"]
1168
1167
 
1169
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1168
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
1170
1169
  return ["Iterable"]
1171
1170
 
1172
1171
  @property
@@ -1174,7 +1173,7 @@ class _SyncPagingOperationBaseSerializer(_PagingOperationBaseSerializer, _SyncOp
1174
1173
  return "iter"
1175
1174
 
1176
1175
  @staticmethod
1177
- def _pager(builder: BuilderType) -> str:
1176
+ def _pager(builder) -> str:
1178
1177
  return builder.get_pager(async_mode=False)
1179
1178
 
1180
1179
  class SyncPagingOperationGenericSerializer(_SyncPagingOperationBaseSerializer, SyncOperationGenericSerializer):
@@ -1184,14 +1183,14 @@ class SyncPagingOperationPython3Serializer(_SyncPagingOperationBaseSerializer, S
1184
1183
  pass
1185
1184
 
1186
1185
  class AsyncPagingOperationSerializer(_PagingOperationBaseSerializer, AsyncOperationSerializer):
1187
- def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: # pylint: no-self-use
1186
+ def _response_docstring_type_wrapper(self, builder) -> List[str]: # pylint: no-self-use
1188
1187
  return [f"~{builder.get_pager_path(async_mode=True)}"]
1189
1188
 
1190
1189
  @property
1191
1190
  def _function_definition(self) -> str:
1192
1191
  return "def"
1193
1192
 
1194
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1193
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
1195
1194
  return ["AsyncIterable"]
1196
1195
 
1197
1196
  @property
@@ -1199,7 +1198,7 @@ class AsyncPagingOperationSerializer(_PagingOperationBaseSerializer, AsyncOperat
1199
1198
  return "AsyncList"
1200
1199
 
1201
1200
  @staticmethod
1202
- def _pager(builder: BuilderType) -> str:
1201
+ def _pager(builder) -> str:
1203
1202
  return builder.get_pager(async_mode=True)
1204
1203
 
1205
1204
 
@@ -1207,19 +1206,19 @@ class AsyncPagingOperationSerializer(_PagingOperationBaseSerializer, AsyncOperat
1207
1206
 
1208
1207
 
1209
1208
  class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=abstract-method
1210
- def cls_type_annotation(self, builder: BuilderType) -> str:
1209
+ def cls_type_annotation(self, builder) -> str:
1211
1210
  return f"# type: ClsType[{super()._response_type_annotation(builder, modify_if_head_as_boolean=False)}]"
1212
1211
 
1213
1212
  @abstractmethod
1214
- def _default_polling_method(self, builder: BuilderType) -> str:
1213
+ def _default_polling_method(self, builder) -> str:
1215
1214
  ...
1216
1215
 
1217
1216
  @abstractmethod
1218
- def _default_no_polling_method(self, builder: BuilderType) -> str:
1217
+ def _default_no_polling_method(self, builder) -> str:
1219
1218
  ...
1220
1219
 
1221
1220
  @abstractmethod
1222
- def _poller(self, builder: BuilderType) -> str:
1221
+ def _poller(self, builder) -> str:
1223
1222
  ...
1224
1223
 
1225
1224
  @property
@@ -1227,7 +1226,7 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
1227
1226
  def _polling_method_type(self):
1228
1227
  ...
1229
1228
 
1230
- def param_description(self, builder: BuilderType) -> List[str]:
1229
+ def param_description(self, builder) -> List[str]:
1231
1230
  retval = super().param_description(builder)
1232
1231
  retval.append(":keyword str continuation_token: A continuation token to restart a poller from a saved state.")
1233
1232
  retval.append(
@@ -1242,7 +1241,7 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
1242
1241
  )
1243
1242
  return retval
1244
1243
 
1245
- def initial_call(self, builder: BuilderType) -> List[str]:
1244
+ def initial_call(self, builder) -> List[str]:
1246
1245
  retval = [f"polling = kwargs.pop('polling', True) # type: Union[bool, {self._polling_method_type}]"]
1247
1246
  retval.append(f"cls = kwargs.pop('cls', None) {self.cls_type_annotation(builder)}")
1248
1247
  retval.append("lro_delay = kwargs.pop(")
@@ -1262,7 +1261,7 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
1262
1261
  retval.append("kwargs.pop('error_map', None)")
1263
1262
  return retval
1264
1263
 
1265
- def return_lro_poller(self, builder: BuilderType) -> List[str]:
1264
+ def return_lro_poller(self, builder) -> List[str]:
1266
1265
  retval = []
1267
1266
  lro_options_str = (
1268
1267
  ", lro_options={'final-state-via': '" + builder.lro_options['final-state-via'] + "'}"
@@ -1295,7 +1294,7 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
1295
1294
  )
1296
1295
  return retval
1297
1296
 
1298
- def get_long_running_output(self, builder: BuilderType) -> List[str]:
1297
+ def get_long_running_output(self, builder) -> List[str]:
1299
1298
  retval = ["def get_long_running_output(pipeline_response):"]
1300
1299
  if builder.lro_response:
1301
1300
  if builder.lro_response.has_headers:
@@ -1316,29 +1315,29 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
1316
1315
 
1317
1316
 
1318
1317
  class _SyncLROOperationBaseSerializer(_LROOperationBaseSerializer, _SyncOperationBaseSerializer): # pylint: disable=abstract-method
1319
- def _response_docstring_text_template(self, builder: BuilderType) -> str: # pylint: disable=no-self-use
1318
+ def _response_docstring_text_template(self, builder) -> str: # pylint: disable=no-self-use
1320
1319
  lro_section = f"An instance of {builder.get_poller(async_mode=False)} "
1321
1320
  if self._cls_docstring_rtype:
1322
1321
  return lro_section + "that returns either {}" + self._cls_docstring_rtype
1323
1322
  return lro_section + "that returns {}"
1324
1323
 
1325
- def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: # pylint: no-self-use
1324
+ def _response_docstring_type_wrapper(self, builder) -> List[str]: # pylint: no-self-use
1326
1325
  return [f"~{builder.get_poller_path(async_mode=False)}"]
1327
1326
 
1328
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1327
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
1329
1328
  return [builder.get_poller(async_mode=False)]
1330
1329
 
1331
- def _default_polling_method(self, builder: BuilderType) -> str:
1330
+ def _default_polling_method(self, builder) -> str:
1332
1331
  return builder.get_default_polling_method(async_mode=False, azure_arm=self.code_model.options["azure_arm"])
1333
1332
 
1334
- def _default_no_polling_method(self, builder: BuilderType) -> str:
1333
+ def _default_no_polling_method(self, builder) -> str:
1335
1334
  return builder.get_default_no_polling_method(async_mode=False)
1336
1335
 
1337
1336
  @property
1338
1337
  def _polling_method_type(self):
1339
1338
  return "azure.core.polling.PollingMethod"
1340
1339
 
1341
- def _poller(self, builder: BuilderType) -> str:
1340
+ def _poller(self, builder) -> str:
1342
1341
  return builder.get_poller(async_mode=False)
1343
1342
 
1344
1343
  class SyncLROOperationGenericSerializer(_SyncLROOperationBaseSerializer, SyncOperationGenericSerializer):
@@ -1349,29 +1348,29 @@ class SyncLROOperationPython3Serializer(_SyncLROOperationBaseSerializer, SyncOpe
1349
1348
 
1350
1349
  class AsyncLROOperationSerializer(_LROOperationBaseSerializer, AsyncOperationSerializer):
1351
1350
 
1352
- def _response_docstring_text_template(self, builder: BuilderType) -> str: # pylint: disable=no-self-use
1351
+ def _response_docstring_text_template(self, builder) -> str: # pylint: disable=no-self-use
1353
1352
  lro_section = f"An instance of {builder.get_poller(async_mode=True)} "
1354
1353
  if self._cls_docstring_rtype:
1355
1354
  return lro_section + "that returns either {}" + self._cls_docstring_rtype
1356
1355
  return lro_section + "that returns {}"
1357
1356
 
1358
- def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]: # pylint: no-self-use
1357
+ def _response_docstring_type_wrapper(self, builder) -> List[str]: # pylint: no-self-use
1359
1358
  return [f"~{builder.get_poller_path(async_mode=True)}"]
1360
1359
 
1361
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1360
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
1362
1361
  return [builder.get_poller(async_mode=True)]
1363
1362
 
1364
- def _default_polling_method(self, builder: BuilderType) -> str:
1363
+ def _default_polling_method(self, builder) -> str:
1365
1364
  return builder.get_default_polling_method(async_mode=True, azure_arm=self.code_model.options["azure_arm"])
1366
1365
 
1367
- def _default_no_polling_method(self, builder: BuilderType) -> str:
1366
+ def _default_no_polling_method(self, builder) -> str:
1368
1367
  return builder.get_default_no_polling_method(async_mode=True)
1369
1368
 
1370
1369
  @property
1371
1370
  def _polling_method_type(self):
1372
1371
  return "azure.core.polling.AsyncPollingMethod"
1373
1372
 
1374
- def _poller(self, builder: BuilderType) -> str:
1373
+ def _poller(self, builder) -> str:
1375
1374
  return builder.get_poller(async_mode=True)
1376
1375
 
1377
1376
 
@@ -1379,7 +1378,7 @@ class AsyncLROOperationSerializer(_LROOperationBaseSerializer, AsyncOperationSer
1379
1378
 
1380
1379
  class _LROPagingOperationBaseSerializer(_LROOperationBaseSerializer, _PagingOperationBaseSerializer): # pylint: disable=abstract-method
1381
1380
 
1382
- def get_long_running_output(self, builder: BuilderType) -> List[str]:
1381
+ def get_long_running_output(self, builder) -> List[str]:
1383
1382
  retval = ["def get_long_running_output(pipeline_response):"]
1384
1383
  retval.append(f" {self._def} internal_get_next(next_link=None):")
1385
1384
  retval.append(" if next_link is None:")
@@ -1397,23 +1396,23 @@ class _SyncLROPagingOperationBaseSerializer( # pylint: disable=abstract-method
1397
1396
  _SyncLROOperationBaseSerializer, _SyncPagingOperationBaseSerializer, _LROPagingOperationBaseSerializer
1398
1397
  ):
1399
1398
 
1400
- def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]:
1399
+ def _response_docstring_type_wrapper(self, builder) -> List[str]:
1401
1400
  return _SyncLROOperationBaseSerializer._response_docstring_type_wrapper(
1402
1401
  self, builder
1403
1402
  ) + _SyncPagingOperationBaseSerializer._response_docstring_type_wrapper(self, builder)
1404
1403
 
1405
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1404
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
1406
1405
  return _SyncLROOperationBaseSerializer._response_type_annotation_wrapper(self, builder) + [
1407
1406
  builder.get_pager(async_mode=False)
1408
1407
  ]
1409
1408
 
1410
- def _response_docstring_text_template(self, builder: BuilderType) -> str:
1409
+ def _response_docstring_text_template(self, builder) -> str:
1411
1410
  lro_doc = _SyncLROOperationBaseSerializer._response_docstring_text_template(self, builder)
1412
1411
  paging_doc = _SyncPagingOperationBaseSerializer._response_docstring_text_template(self, builder)
1413
1412
  paging_doc = paging_doc.replace(paging_doc[0], paging_doc[0].lower(), 1)
1414
1413
  return lro_doc.format(paging_doc).replace(self._cls_docstring_rtype, "", 1).replace("either ", "", 1)
1415
1414
 
1416
- def cls_type_annotation(self, builder: BuilderType) -> str:
1415
+ def cls_type_annotation(self, builder) -> str:
1417
1416
  return f"# type: ClsType[{self._response_type_annotation(builder, modify_if_head_as_boolean=False)}]"
1418
1417
 
1419
1418
  class SyncLROPagingOperationGenericSerializer(_SyncLROPagingOperationBaseSerializer, SyncOperationGenericSerializer):
@@ -1429,17 +1428,17 @@ class AsyncLROPagingOperationSerializer(
1429
1428
  def _function_definition(self) -> str:
1430
1429
  return "async def"
1431
1430
 
1432
- def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]:
1431
+ def _response_docstring_type_wrapper(self, builder) -> List[str]:
1433
1432
  return AsyncLROOperationSerializer._response_docstring_type_wrapper(
1434
1433
  self, builder
1435
1434
  ) + AsyncPagingOperationSerializer._response_docstring_type_wrapper(self, builder)
1436
1435
 
1437
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1436
+ def _response_type_annotation_wrapper(self, builder: LROPagingOperation) -> List[str]:
1438
1437
  return AsyncLROOperationSerializer._response_type_annotation_wrapper(self, builder) + [
1439
1438
  builder.get_pager(async_mode=True)
1440
1439
  ]
1441
1440
 
1442
- def _response_docstring_text_template(self, builder: BuilderType) -> str:
1441
+ def _response_docstring_text_template(self, builder) -> str:
1443
1442
  lro_doc = AsyncLROOperationSerializer._response_docstring_text_template(self, builder)
1444
1443
  paging_doc = AsyncPagingOperationSerializer._response_docstring_text_template(self, builder)
1445
1444
  paging_doc = paging_doc.replace(paging_doc[0], paging_doc[0].lower(), 1)
@@ -1447,7 +1446,7 @@ class AsyncLROPagingOperationSerializer(
1447
1446
 
1448
1447
 
1449
1448
  def get_operation_serializer(
1450
- builder: BuilderType,
1449
+ builder,
1451
1450
  code_model,
1452
1451
  async_mode: bool,
1453
1452
  is_python3_file: bool,
@@ -7,6 +7,7 @@ import re
7
7
  import copy
8
8
  from typing import cast, Any, Dict, List, Match, Optional
9
9
  from .python_mappings import basic_latin_chars, reserved_words, PadType
10
+ from ..codegen.models.utils import JSON_REGEXP
10
11
 
11
12
  def _get_all_values(all_headers: List[Dict[str, Any]]) -> List[str]:
12
13
  content_types: List[str] = []
@@ -24,7 +25,7 @@ def _get_all_values(all_headers: List[Dict[str, Any]]) -> List[str]:
24
25
  return content_types
25
26
 
26
27
  def _get_default_value(all_values: List[str]) -> str:
27
- json_values = [v for v in all_values if "json" in v]
28
+ json_values = [v for v in all_values if JSON_REGEXP.match(v)]
28
29
  if json_values:
29
30
  if "application/json" in json_values:
30
31
  return "application/json"
package/install.py CHANGED
@@ -43,6 +43,7 @@ def main():
43
43
  venv_context = env_builder.context
44
44
 
45
45
  python_run(venv_context, "pip", ["install", "-U", "pip"])
46
+ python_run(venv_context, "pip", ["install", "-r", "requirements.txt"])
46
47
  python_run(venv_context, "pip", ["install", "-e", str(_ROOT_DIR)])
47
48
 
48
49
  if __name__ == "__main__":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "5.12.0",
3
+ "version": "5.12.1",
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.8"
30
+ "@microsoft.azure/autorest.testserver": "^3.1.11"
31
31
  },
32
32
  "files": [
33
33
  "autorest/**/*.py",
package/setup.py CHANGED
@@ -48,7 +48,7 @@ setup(
48
48
  "json-rpc",
49
49
  "Jinja2 >= 2.11", # I need "include" and auto-context + blank line are not indented by default
50
50
  "pyyaml",
51
- "mistune < 2.0.0",
51
+ "mistune < 2.0.0", # Need to pin mistune's max version so m2r doesn't break
52
52
  "m2r",
53
53
  "black",
54
54
  ],