@autorest/python 5.11.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.
Files changed (50) hide show
  1. package/ChangeLog.md +68 -0
  2. package/autorest/codegen/__init__.py +5 -5
  3. package/autorest/codegen/models/__init__.py +3 -23
  4. package/autorest/codegen/models/base_builder.py +2 -5
  5. package/autorest/codegen/models/client.py +5 -3
  6. package/autorest/codegen/models/code_model.py +14 -1
  7. package/autorest/codegen/models/operation_group.py +7 -7
  8. package/autorest/codegen/models/parameter.py +4 -3
  9. package/autorest/codegen/models/parameter_list.py +32 -27
  10. package/autorest/codegen/models/request_builder.py +5 -1
  11. package/autorest/codegen/models/request_builder_parameter.py +4 -3
  12. package/autorest/codegen/models/request_builder_parameter_list.py +18 -11
  13. package/autorest/codegen/models/rest.py +3 -2
  14. package/autorest/codegen/models/utils.py +8 -0
  15. package/autorest/codegen/serializers/__init__.py +52 -51
  16. package/autorest/codegen/serializers/builder_serializer.py +150 -146
  17. package/autorest/codegen/serializers/client_serializer.py +37 -9
  18. package/autorest/codegen/serializers/general_serializer.py +7 -5
  19. package/autorest/codegen/serializers/import_serializer.py +6 -6
  20. package/autorest/codegen/serializers/metadata_serializer.py +2 -2
  21. package/autorest/codegen/serializers/model_base_serializer.py +3 -3
  22. package/autorest/codegen/serializers/model_generic_serializer.py +1 -1
  23. package/autorest/codegen/serializers/model_python3_serializer.py +1 -1
  24. package/autorest/codegen/serializers/{operation_group_serializer.py → operation_groups_serializer.py} +27 -29
  25. package/autorest/codegen/serializers/operations_init_serializer.py +34 -2
  26. package/autorest/codegen/serializers/patch_serializer.py +15 -0
  27. package/autorest/codegen/serializers/rest_serializer.py +9 -4
  28. package/autorest/codegen/serializers/utils.py +2 -2
  29. package/autorest/codegen/templates/config.py.jinja2 +1 -11
  30. package/autorest/codegen/templates/init.py.jinja2 +4 -5
  31. package/autorest/codegen/templates/metadata.json.jinja2 +2 -2
  32. package/autorest/codegen/templates/model_init.py.jinja2 +1 -1
  33. package/autorest/codegen/templates/{operations_class.py.jinja2 → operation_group.py.jinja2} +2 -0
  34. package/autorest/codegen/templates/operation_groups_container.py.jinja2 +26 -0
  35. package/autorest/codegen/templates/operation_tools.jinja2 +7 -0
  36. package/autorest/codegen/templates/operations_folder_init.py.jinja2 +13 -0
  37. package/autorest/codegen/templates/patch.py.jinja2 +31 -0
  38. package/autorest/codegen/templates/request_builder.py.jinja2 +7 -2
  39. package/autorest/codegen/templates/request_builders.py.jinja2 +3 -3
  40. package/autorest/codegen/templates/setup.py.jinja2 +1 -1
  41. package/autorest/multiapi/serializers/__init__.py +3 -3
  42. package/autorest/multiapi/serializers/import_serializer.py +5 -5
  43. package/autorest/namer/name_converter.py +3 -1
  44. package/install.py +1 -0
  45. package/package.json +2 -2
  46. package/setup.py +1 -0
  47. package/autorest/codegen/templates/operations_class_mixin.py.jinja2 +0 -16
  48. package/autorest/codegen/templates/operations_container.py.jinja2 +0 -39
  49. package/autorest/codegen/templates/operations_container_init.py.jinja2 +0 -24
  50. package/autorest/codegen/templates/operations_container_mixin.py.jinja2 +0 -20
@@ -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,
@@ -57,7 +56,7 @@ def _json_dumps_template(template_representation: Any) -> Any:
57
56
  def _serialize_files_or_data_dict(multipart_parameters: List[Parameter]) -> str:
58
57
  # only for template use
59
58
  template = {
60
- param.serialized_name: param.schema.get_files_and_data_template_representation(
59
+ f'"{param.serialized_name}"': param.schema.get_files_and_data_template_representation(
61
60
  optional=not param.required,
62
61
  description=param.description,
63
62
  )
@@ -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:
@@ -542,13 +541,13 @@ class RequestBuilderGenericSerializer(_RequestBuilderBaseSerializer):
542
541
  @staticmethod
543
542
  def _method_signature_and_response_type_annotation_template(method_signature: str, response_type_annotation: str):
544
543
  return utils.method_signature_and_response_type_annotation_template(
545
- is_python_3_file=False, method_signature=method_signature, response_type_annotation=response_type_annotation
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):
549
- return builder.parameters.kwargs_to_pop(is_python_3_file=False)
547
+ def _get_kwargs_to_pop(self, builder):
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
@@ -564,13 +563,13 @@ class RequestBuilderPython3Serializer(_RequestBuilderBaseSerializer):
564
563
  @staticmethod
565
564
  def _method_signature_and_response_type_annotation_template(method_signature: str, response_type_annotation: str):
566
565
  return utils.method_signature_and_response_type_annotation_template(
567
- is_python_3_file=True, method_signature=method_signature, response_type_annotation=response_type_annotation
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):
571
- return builder.parameters.kwargs_to_pop(is_python_3_file=True)
569
+ def _get_kwargs_to_pop(self, builder):
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,35 +674,35 @@ 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 ""
698
697
  body_kwarg_to_pass = builder.body_kwargs_to_pass_to_request_builder[0]
699
698
  if self.code_model.options["models_mode"]:
700
699
  return (
701
- f"{body_kwarg_to_pass} = self._serialize.body({body_param.serialized_name}, "
700
+ f"_{body_kwarg_to_pass} = self._serialize.body({body_param.serialized_name}, "
702
701
  f"'{ body_param.serialization_type }'{body_is_xml}{ pass_ser_ctxt })"
703
702
  )
704
- return f"{body_kwarg_to_pass} = {body_param.serialized_name}"
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
@@ -728,11 +727,11 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
728
727
  retval.append(" " + serialize_body_call)
729
728
  if len(builder.body_kwargs_to_pass_to_request_builder) == 1:
730
729
  retval.append("else:")
731
- retval.append(f" {body_kwarg} = None")
730
+ retval.append(f" _{body_kwarg} = None")
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":
@@ -743,12 +742,12 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
743
742
  return retval
744
743
  except AttributeError:
745
744
  pass
746
- retval.append(f"{body_kwarg.serialized_name} = {body_param.serialized_name}")
745
+ retval.append(f"_{body_kwarg.serialized_name} = {body_param.serialized_name}")
747
746
  return retval
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]:
@@ -790,7 +789,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
790
789
  if self.code_model.options["version_tolerant"]:
791
790
  body_params_to_initialize = [p for p in body_params_to_initialize if p != "files"]
792
791
  for k in body_params_to_initialize:
793
- retval.append(f"{k} = None")
792
+ retval.append(f"_{k} = None")
794
793
  if builder.parameters.grouped:
795
794
  # request builders don't allow grouped parameters, so we group them before making the call
796
795
  retval.extend(_serialize_grouped_body(builder))
@@ -799,8 +798,8 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
799
798
  # unflatten before passing to request builder as well
800
799
  retval.extend(_serialize_flattened_body(builder))
801
800
  if request_builder.multipart or request_builder.parameters.data_inputs:
802
- param_name = "files" if request_builder.multipart else "data"
803
801
  if not self.code_model.options["version_tolerant"]:
802
+ param_name = "_files" if request_builder.multipart else "_data"
804
803
  retval.extend(_serialize_files_and_data_body(builder, param_name))
805
804
  elif builder.parameters.has_body and not builder.parameters.body[0].constant:
806
805
  retval.extend(self._serialize_body_parameters(builder))
@@ -823,24 +822,29 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
823
822
  continue
824
823
  high_level_name = cast(RequestBuilderParameter, parameter).name_in_high_level_operation
825
824
  retval.append(f" {parameter.serialized_name}={high_level_name},")
826
- template_url = template_url or f"self.{builder.name}.metadata['url']"
827
- retval.append(f" template_url={template_url},")
825
+ if not self.code_model.options["version_tolerant"]:
826
+ template_url = template_url or f"self.{builder.name}.metadata['url']"
827
+ retval.append(f" template_url={template_url},")
828
828
  retval.append(f")")
829
829
  if not self.code_model.options["version_tolerant"]:
830
830
  pass_files = ""
831
831
  if "files" in builder.body_kwargs_to_pass_to_request_builder:
832
- pass_files = ", files"
832
+ pass_files = ", _files"
833
833
  retval.append(f"request = _convert_request(request{pass_files})")
834
834
  if builder.parameters.path:
835
835
  retval.extend(self.serialize_path(builder))
836
+ url_to_format = "request.url"
837
+ if self.code_model.options["version_tolerant"] and template_url:
838
+ url_to_format = template_url
836
839
  retval.append(
837
- "request.url = self._client.format_url(request.url{})".format(
840
+ "request.url = self._client.format_url({}{})".format(
841
+ url_to_format,
838
842
  ", **path_format_arguments" if builder.parameters.path else ""
839
843
  )
840
844
  )
841
845
  return retval
842
846
 
843
- def call_request_builder(self, builder: BuilderType) -> List[str]:
847
+ def call_request_builder(self, builder) -> List[str]:
844
848
  return self._call_request_builder_helper(builder, builder.request_builder)
845
849
 
846
850
  def response_headers_and_deserialization(
@@ -881,7 +885,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
881
885
  def _call_method(self) -> str:
882
886
  ...
883
887
 
884
- def handle_error_response(self, builder: BuilderType) -> List[str]:
888
+ def handle_error_response(self, builder) -> List[str]:
885
889
  retval = [f"if response.status_code not in {str(builder.success_status_code)}:"]
886
890
  retval.append(" map_error(status_code=response.status_code, response=response, error_map=error_map)")
887
891
  error_model = ""
@@ -896,7 +900,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
896
900
  ))
897
901
  return retval
898
902
 
899
- def handle_response(self, builder: BuilderType) -> List[str]:
903
+ def handle_response(self, builder) -> List[str]:
900
904
  retval: List[str] = ["response = pipeline_response.http_response"]
901
905
  retval.append("")
902
906
  retval.extend(self.handle_error_response(builder))
@@ -933,7 +937,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
933
937
  retval.append("return 200 <= response.status_code <= 299")
934
938
  return retval
935
939
 
936
- def error_map(self, builder: BuilderType) -> List[str]:
940
+ def error_map(self, builder) -> List[str]:
937
941
  retval = ["error_map = {"]
938
942
  if builder.status_code_exceptions:
939
943
  if not 401 in builder.status_code_exceptions_status_codes:
@@ -981,7 +985,7 @@ class _OperationBaseSerializer(_BuilderBaseSerializer): # pylint: disable=abstr
981
985
  return retval
982
986
 
983
987
  @staticmethod
984
- def get_metadata_url(builder: BuilderType) -> str:
988
+ def get_metadata_url(builder) -> str:
985
989
  return f"{builder.python_name}.metadata = {{'url': '{ builder.request_builder.url }'}} # type: ignore"
986
990
 
987
991
  class _SyncOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=abstract-method
@@ -1005,11 +1009,11 @@ class SyncOperationGenericSerializer(_SyncOperationBaseSerializer):
1005
1009
  @staticmethod
1006
1010
  def _method_signature_and_response_type_annotation_template(method_signature: str, response_type_annotation: str):
1007
1011
  return utils.method_signature_and_response_type_annotation_template(
1008
- is_python_3_file=False, method_signature=method_signature, response_type_annotation=response_type_annotation
1012
+ is_python3_file=False, method_signature=method_signature, response_type_annotation=response_type_annotation
1009
1013
  )
1010
1014
 
1011
- def _get_kwargs_to_pop(self, builder: BuilderType):
1012
- return builder.parameters.kwargs_to_pop(is_python_3_file=False)
1015
+ def _get_kwargs_to_pop(self, builder):
1016
+ return builder.parameters.kwargs_to_pop(is_python3_file=False)
1013
1017
 
1014
1018
 
1015
1019
  class SyncOperationPython3Serializer(_SyncOperationBaseSerializer):
@@ -1020,11 +1024,11 @@ class SyncOperationPython3Serializer(_SyncOperationBaseSerializer):
1020
1024
  @staticmethod
1021
1025
  def _method_signature_and_response_type_annotation_template(method_signature: str, response_type_annotation: str):
1022
1026
  return utils.method_signature_and_response_type_annotation_template(
1023
- is_python_3_file=True, method_signature=method_signature, response_type_annotation=response_type_annotation
1027
+ is_python3_file=True, method_signature=method_signature, response_type_annotation=response_type_annotation
1024
1028
  )
1025
1029
 
1026
- def _get_kwargs_to_pop(self, builder: BuilderType):
1027
- return builder.parameters.kwargs_to_pop(is_python_3_file=True)
1030
+ def _get_kwargs_to_pop(self, builder):
1031
+ return builder.parameters.kwargs_to_pop(is_python3_file=True)
1028
1032
 
1029
1033
  class AsyncOperationSerializer(SyncOperationPython3Serializer):
1030
1034
 
@@ -1045,19 +1049,19 @@ class AsyncOperationSerializer(SyncOperationPython3Serializer):
1045
1049
 
1046
1050
 
1047
1051
  class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=abstract-method
1048
- 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
1049
1053
  if self._cls_docstring_rtype:
1050
1054
  return "An iterator like instance of either {}" + self._cls_docstring_rtype
1051
1055
  return "An iterator like instance of {}"
1052
1056
 
1053
- def cls_type_annotation(self, builder: BuilderType) -> str:
1057
+ def cls_type_annotation(self, builder) -> str:
1054
1058
  interior = super()._response_type_annotation(builder, modify_if_head_as_boolean=False)
1055
1059
  return f"# type: ClsType[{interior}]"
1056
1060
 
1057
- def call_next_link_request_builder(self, builder: BuilderType) -> List[str]:
1061
+ def call_next_link_request_builder(self, builder) -> List[str]:
1058
1062
  if builder.next_request_builder:
1059
1063
  request_builder = builder.next_request_builder
1060
- template_url = f"'{request_builder.url}'"
1064
+ template_url = None if self.code_model.options["version_tolerant"] else f"'{request_builder.url}'"
1061
1065
  else:
1062
1066
  request_builder = builder.request_builder
1063
1067
  template_url = "next_link"
@@ -1068,7 +1072,7 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
1068
1072
  template_url=template_url,
1069
1073
  )
1070
1074
 
1071
- def _prepare_request_callback(self, builder: BuilderType) -> List[str]:
1075
+ def _prepare_request_callback(self, builder) -> List[str]:
1072
1076
  retval = ["def prepare_request(next_link=None):"]
1073
1077
  retval.append(" if not next_link:")
1074
1078
  retval.extend([
@@ -1101,10 +1105,10 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
1101
1105
 
1102
1106
  @staticmethod
1103
1107
  @abstractmethod
1104
- def _pager(builder: BuilderType) -> str:
1108
+ def _pager(builder) -> str:
1105
1109
  ...
1106
1110
 
1107
- def _extract_data_callback(self, builder: BuilderType) -> List[str]:
1111
+ def _extract_data_callback(self, builder) -> List[str]:
1108
1112
  retval = [f"{self._def} extract_data(pipeline_response):"]
1109
1113
  response = builder.responses[0]
1110
1114
  deserialized = (
@@ -1129,7 +1133,7 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
1129
1133
  retval.append(f" return {next_link_property}, {self._list_type_returned_to_users}(list_of_elem)")
1130
1134
  return retval
1131
1135
 
1132
- def _get_next_callback(self, builder: BuilderType) -> List[str]:
1136
+ def _get_next_callback(self, builder) -> List[str]:
1133
1137
  retval = [f"{self._def} get_next(next_link=None):"]
1134
1138
  retval.append(" request = prepare_request(next_link)")
1135
1139
  retval.append("")
@@ -1147,7 +1151,7 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
1147
1151
  retval.append(" return pipeline_response")
1148
1152
  return retval
1149
1153
 
1150
- def set_up_params_for_pager(self, builder: BuilderType) -> List[str]:
1154
+ def set_up_params_for_pager(self, builder) -> List[str]:
1151
1155
  retval = [f"cls = kwargs.pop('cls', None) {self.cls_type_annotation(builder)}"]
1152
1156
  retval.extend(self.error_map(builder))
1153
1157
  retval.extend(self._prepare_request_callback(builder))
@@ -1158,10 +1162,10 @@ class _PagingOperationBaseSerializer(_OperationBaseSerializer): # pylint: disab
1158
1162
  return retval
1159
1163
 
1160
1164
  class _SyncPagingOperationBaseSerializer(_PagingOperationBaseSerializer, _SyncOperationBaseSerializer): # pylint: disable=abstract-method
1161
- 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
1162
1166
  return [f"~{builder.get_pager_path(async_mode=False)}"]
1163
1167
 
1164
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1168
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
1165
1169
  return ["Iterable"]
1166
1170
 
1167
1171
  @property
@@ -1169,7 +1173,7 @@ class _SyncPagingOperationBaseSerializer(_PagingOperationBaseSerializer, _SyncOp
1169
1173
  return "iter"
1170
1174
 
1171
1175
  @staticmethod
1172
- def _pager(builder: BuilderType) -> str:
1176
+ def _pager(builder) -> str:
1173
1177
  return builder.get_pager(async_mode=False)
1174
1178
 
1175
1179
  class SyncPagingOperationGenericSerializer(_SyncPagingOperationBaseSerializer, SyncOperationGenericSerializer):
@@ -1179,14 +1183,14 @@ class SyncPagingOperationPython3Serializer(_SyncPagingOperationBaseSerializer, S
1179
1183
  pass
1180
1184
 
1181
1185
  class AsyncPagingOperationSerializer(_PagingOperationBaseSerializer, AsyncOperationSerializer):
1182
- 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
1183
1187
  return [f"~{builder.get_pager_path(async_mode=True)}"]
1184
1188
 
1185
1189
  @property
1186
1190
  def _function_definition(self) -> str:
1187
1191
  return "def"
1188
1192
 
1189
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1193
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
1190
1194
  return ["AsyncIterable"]
1191
1195
 
1192
1196
  @property
@@ -1194,7 +1198,7 @@ class AsyncPagingOperationSerializer(_PagingOperationBaseSerializer, AsyncOperat
1194
1198
  return "AsyncList"
1195
1199
 
1196
1200
  @staticmethod
1197
- def _pager(builder: BuilderType) -> str:
1201
+ def _pager(builder) -> str:
1198
1202
  return builder.get_pager(async_mode=True)
1199
1203
 
1200
1204
 
@@ -1202,19 +1206,19 @@ class AsyncPagingOperationSerializer(_PagingOperationBaseSerializer, AsyncOperat
1202
1206
 
1203
1207
 
1204
1208
  class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=abstract-method
1205
- def cls_type_annotation(self, builder: BuilderType) -> str:
1209
+ def cls_type_annotation(self, builder) -> str:
1206
1210
  return f"# type: ClsType[{super()._response_type_annotation(builder, modify_if_head_as_boolean=False)}]"
1207
1211
 
1208
1212
  @abstractmethod
1209
- def _default_polling_method(self, builder: BuilderType) -> str:
1213
+ def _default_polling_method(self, builder) -> str:
1210
1214
  ...
1211
1215
 
1212
1216
  @abstractmethod
1213
- def _default_no_polling_method(self, builder: BuilderType) -> str:
1217
+ def _default_no_polling_method(self, builder) -> str:
1214
1218
  ...
1215
1219
 
1216
1220
  @abstractmethod
1217
- def _poller(self, builder: BuilderType) -> str:
1221
+ def _poller(self, builder) -> str:
1218
1222
  ...
1219
1223
 
1220
1224
  @property
@@ -1222,7 +1226,7 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
1222
1226
  def _polling_method_type(self):
1223
1227
  ...
1224
1228
 
1225
- def param_description(self, builder: BuilderType) -> List[str]:
1229
+ def param_description(self, builder) -> List[str]:
1226
1230
  retval = super().param_description(builder)
1227
1231
  retval.append(":keyword str continuation_token: A continuation token to restart a poller from a saved state.")
1228
1232
  retval.append(
@@ -1237,7 +1241,7 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
1237
1241
  )
1238
1242
  return retval
1239
1243
 
1240
- def initial_call(self, builder: BuilderType) -> List[str]:
1244
+ def initial_call(self, builder) -> List[str]:
1241
1245
  retval = [f"polling = kwargs.pop('polling', True) # type: Union[bool, {self._polling_method_type}]"]
1242
1246
  retval.append(f"cls = kwargs.pop('cls', None) {self.cls_type_annotation(builder)}")
1243
1247
  retval.append("lro_delay = kwargs.pop(")
@@ -1257,7 +1261,7 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
1257
1261
  retval.append("kwargs.pop('error_map', None)")
1258
1262
  return retval
1259
1263
 
1260
- def return_lro_poller(self, builder: BuilderType) -> List[str]:
1264
+ def return_lro_poller(self, builder) -> List[str]:
1261
1265
  retval = []
1262
1266
  lro_options_str = (
1263
1267
  ", lro_options={'final-state-via': '" + builder.lro_options['final-state-via'] + "'}"
@@ -1290,7 +1294,7 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
1290
1294
  )
1291
1295
  return retval
1292
1296
 
1293
- def get_long_running_output(self, builder: BuilderType) -> List[str]:
1297
+ def get_long_running_output(self, builder) -> List[str]:
1294
1298
  retval = ["def get_long_running_output(pipeline_response):"]
1295
1299
  if builder.lro_response:
1296
1300
  if builder.lro_response.has_headers:
@@ -1311,29 +1315,29 @@ class _LROOperationBaseSerializer(_OperationBaseSerializer): # pylint: disable=
1311
1315
 
1312
1316
 
1313
1317
  class _SyncLROOperationBaseSerializer(_LROOperationBaseSerializer, _SyncOperationBaseSerializer): # pylint: disable=abstract-method
1314
- 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
1315
1319
  lro_section = f"An instance of {builder.get_poller(async_mode=False)} "
1316
1320
  if self._cls_docstring_rtype:
1317
1321
  return lro_section + "that returns either {}" + self._cls_docstring_rtype
1318
1322
  return lro_section + "that returns {}"
1319
1323
 
1320
- 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
1321
1325
  return [f"~{builder.get_poller_path(async_mode=False)}"]
1322
1326
 
1323
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1327
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
1324
1328
  return [builder.get_poller(async_mode=False)]
1325
1329
 
1326
- def _default_polling_method(self, builder: BuilderType) -> str:
1330
+ def _default_polling_method(self, builder) -> str:
1327
1331
  return builder.get_default_polling_method(async_mode=False, azure_arm=self.code_model.options["azure_arm"])
1328
1332
 
1329
- def _default_no_polling_method(self, builder: BuilderType) -> str:
1333
+ def _default_no_polling_method(self, builder) -> str:
1330
1334
  return builder.get_default_no_polling_method(async_mode=False)
1331
1335
 
1332
1336
  @property
1333
1337
  def _polling_method_type(self):
1334
1338
  return "azure.core.polling.PollingMethod"
1335
1339
 
1336
- def _poller(self, builder: BuilderType) -> str:
1340
+ def _poller(self, builder) -> str:
1337
1341
  return builder.get_poller(async_mode=False)
1338
1342
 
1339
1343
  class SyncLROOperationGenericSerializer(_SyncLROOperationBaseSerializer, SyncOperationGenericSerializer):
@@ -1344,29 +1348,29 @@ class SyncLROOperationPython3Serializer(_SyncLROOperationBaseSerializer, SyncOpe
1344
1348
 
1345
1349
  class AsyncLROOperationSerializer(_LROOperationBaseSerializer, AsyncOperationSerializer):
1346
1350
 
1347
- 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
1348
1352
  lro_section = f"An instance of {builder.get_poller(async_mode=True)} "
1349
1353
  if self._cls_docstring_rtype:
1350
1354
  return lro_section + "that returns either {}" + self._cls_docstring_rtype
1351
1355
  return lro_section + "that returns {}"
1352
1356
 
1353
- 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
1354
1358
  return [f"~{builder.get_poller_path(async_mode=True)}"]
1355
1359
 
1356
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1360
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
1357
1361
  return [builder.get_poller(async_mode=True)]
1358
1362
 
1359
- def _default_polling_method(self, builder: BuilderType) -> str:
1363
+ def _default_polling_method(self, builder) -> str:
1360
1364
  return builder.get_default_polling_method(async_mode=True, azure_arm=self.code_model.options["azure_arm"])
1361
1365
 
1362
- def _default_no_polling_method(self, builder: BuilderType) -> str:
1366
+ def _default_no_polling_method(self, builder) -> str:
1363
1367
  return builder.get_default_no_polling_method(async_mode=True)
1364
1368
 
1365
1369
  @property
1366
1370
  def _polling_method_type(self):
1367
1371
  return "azure.core.polling.AsyncPollingMethod"
1368
1372
 
1369
- def _poller(self, builder: BuilderType) -> str:
1373
+ def _poller(self, builder) -> str:
1370
1374
  return builder.get_poller(async_mode=True)
1371
1375
 
1372
1376
 
@@ -1374,7 +1378,7 @@ class AsyncLROOperationSerializer(_LROOperationBaseSerializer, AsyncOperationSer
1374
1378
 
1375
1379
  class _LROPagingOperationBaseSerializer(_LROOperationBaseSerializer, _PagingOperationBaseSerializer): # pylint: disable=abstract-method
1376
1380
 
1377
- def get_long_running_output(self, builder: BuilderType) -> List[str]:
1381
+ def get_long_running_output(self, builder) -> List[str]:
1378
1382
  retval = ["def get_long_running_output(pipeline_response):"]
1379
1383
  retval.append(f" {self._def} internal_get_next(next_link=None):")
1380
1384
  retval.append(" if next_link is None:")
@@ -1392,23 +1396,23 @@ class _SyncLROPagingOperationBaseSerializer( # pylint: disable=abstract-method
1392
1396
  _SyncLROOperationBaseSerializer, _SyncPagingOperationBaseSerializer, _LROPagingOperationBaseSerializer
1393
1397
  ):
1394
1398
 
1395
- def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]:
1399
+ def _response_docstring_type_wrapper(self, builder) -> List[str]:
1396
1400
  return _SyncLROOperationBaseSerializer._response_docstring_type_wrapper(
1397
1401
  self, builder
1398
1402
  ) + _SyncPagingOperationBaseSerializer._response_docstring_type_wrapper(self, builder)
1399
1403
 
1400
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1404
+ def _response_type_annotation_wrapper(self, builder) -> List[str]:
1401
1405
  return _SyncLROOperationBaseSerializer._response_type_annotation_wrapper(self, builder) + [
1402
1406
  builder.get_pager(async_mode=False)
1403
1407
  ]
1404
1408
 
1405
- def _response_docstring_text_template(self, builder: BuilderType) -> str:
1409
+ def _response_docstring_text_template(self, builder) -> str:
1406
1410
  lro_doc = _SyncLROOperationBaseSerializer._response_docstring_text_template(self, builder)
1407
1411
  paging_doc = _SyncPagingOperationBaseSerializer._response_docstring_text_template(self, builder)
1408
1412
  paging_doc = paging_doc.replace(paging_doc[0], paging_doc[0].lower(), 1)
1409
1413
  return lro_doc.format(paging_doc).replace(self._cls_docstring_rtype, "", 1).replace("either ", "", 1)
1410
1414
 
1411
- def cls_type_annotation(self, builder: BuilderType) -> str:
1415
+ def cls_type_annotation(self, builder) -> str:
1412
1416
  return f"# type: ClsType[{self._response_type_annotation(builder, modify_if_head_as_boolean=False)}]"
1413
1417
 
1414
1418
  class SyncLROPagingOperationGenericSerializer(_SyncLROPagingOperationBaseSerializer, SyncOperationGenericSerializer):
@@ -1424,17 +1428,17 @@ class AsyncLROPagingOperationSerializer(
1424
1428
  def _function_definition(self) -> str:
1425
1429
  return "async def"
1426
1430
 
1427
- def _response_docstring_type_wrapper(self, builder: BuilderType) -> List[str]:
1431
+ def _response_docstring_type_wrapper(self, builder) -> List[str]:
1428
1432
  return AsyncLROOperationSerializer._response_docstring_type_wrapper(
1429
1433
  self, builder
1430
1434
  ) + AsyncPagingOperationSerializer._response_docstring_type_wrapper(self, builder)
1431
1435
 
1432
- def _response_type_annotation_wrapper(self, builder: BuilderType) -> List[str]:
1436
+ def _response_type_annotation_wrapper(self, builder: LROPagingOperation) -> List[str]:
1433
1437
  return AsyncLROOperationSerializer._response_type_annotation_wrapper(self, builder) + [
1434
1438
  builder.get_pager(async_mode=True)
1435
1439
  ]
1436
1440
 
1437
- def _response_docstring_text_template(self, builder: BuilderType) -> str:
1441
+ def _response_docstring_text_template(self, builder) -> str:
1438
1442
  lro_doc = AsyncLROOperationSerializer._response_docstring_text_template(self, builder)
1439
1443
  paging_doc = AsyncPagingOperationSerializer._response_docstring_text_template(self, builder)
1440
1444
  paging_doc = paging_doc.replace(paging_doc[0], paging_doc[0].lower(), 1)
@@ -1442,17 +1446,17 @@ class AsyncLROPagingOperationSerializer(
1442
1446
 
1443
1447
 
1444
1448
  def get_operation_serializer(
1445
- builder: BuilderType,
1449
+ builder,
1446
1450
  code_model,
1447
1451
  async_mode: bool,
1448
- is_python_3_file: bool,
1452
+ is_python3_file: bool,
1449
1453
  ) -> _OperationBaseSerializer:
1450
1454
  retcls = _OperationBaseSerializer
1451
1455
  if isinstance(builder, LROPagingOperation):
1452
1456
  retcls = (
1453
1457
  AsyncLROPagingOperationSerializer if async_mode
1454
1458
  else (
1455
- SyncLROPagingOperationPython3Serializer if is_python_3_file
1459
+ SyncLROPagingOperationPython3Serializer if is_python3_file
1456
1460
  else SyncLROPagingOperationGenericSerializer
1457
1461
  )
1458
1462
  )
@@ -1460,22 +1464,22 @@ def get_operation_serializer(
1460
1464
  if isinstance(builder, LROOperation):
1461
1465
  retcls = (
1462
1466
  AsyncLROOperationSerializer if async_mode
1463
- else (SyncLROOperationPython3Serializer if is_python_3_file else SyncLROOperationGenericSerializer)
1467
+ else (SyncLROOperationPython3Serializer if is_python3_file else SyncLROOperationGenericSerializer)
1464
1468
  )
1465
1469
  return retcls(code_model)
1466
1470
  if isinstance(builder, PagingOperation):
1467
1471
  retcls = (
1468
1472
  AsyncPagingOperationSerializer if async_mode
1469
- else (SyncPagingOperationPython3Serializer if is_python_3_file else SyncPagingOperationGenericSerializer)
1473
+ else (SyncPagingOperationPython3Serializer if is_python3_file else SyncPagingOperationGenericSerializer)
1470
1474
  )
1471
1475
  return retcls(code_model)
1472
1476
  retcls = (
1473
1477
  AsyncOperationSerializer if async_mode
1474
- else (SyncOperationPython3Serializer if is_python_3_file else SyncOperationGenericSerializer)
1478
+ else (SyncOperationPython3Serializer if is_python3_file else SyncOperationGenericSerializer)
1475
1479
  )
1476
1480
  return retcls(code_model)
1477
1481
 
1478
1482
 
1479
- def get_request_builder_serializer(code_model, is_python_3_file: bool) -> _RequestBuilderBaseSerializer:
1480
- retcls = RequestBuilderPython3Serializer if is_python_3_file else RequestBuilderGenericSerializer
1483
+ def get_request_builder_serializer(code_model, is_python3_file: bool) -> _RequestBuilderBaseSerializer:
1484
+ retcls = RequestBuilderPython3Serializer if is_python3_file else RequestBuilderGenericSerializer
1481
1485
  return retcls(code_model)