@autorest/python 6.13.12 → 6.13.13

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.
@@ -136,9 +136,11 @@ def build_policies(
136
136
  "self._config.user_agent_policy",
137
137
  "self._config.proxy_policy",
138
138
  "policies.ContentDecodePolicy(**kwargs)",
139
- f"{async_prefix}ARMAutoResourceProviderRegistrationPolicy()"
140
- if is_arm
141
- else None,
139
+ (
140
+ f"{async_prefix}ARMAutoResourceProviderRegistrationPolicy()"
141
+ if is_arm
142
+ else None
143
+ ),
142
144
  "self._config.redirect_policy",
143
145
  "self._config.retry_policy",
144
146
  "self._config.authentication_policy",
@@ -62,9 +62,11 @@ class OptionsRetriever:
62
62
  def license_header(self) -> str:
63
63
  license_header = self.options.get(
64
64
  "header-text",
65
- DEFAULT_HEADER_TEXT.format(company_name=self.company_name)
66
- if self.company_name
67
- else "",
65
+ (
66
+ DEFAULT_HEADER_TEXT.format(company_name=self.company_name)
67
+ if self.company_name
68
+ else ""
69
+ ),
68
70
  )
69
71
  if license_header:
70
72
  license_header = license_header.replace("\n", "\n# ")
@@ -100,16 +100,13 @@ class BaseBuilder(
100
100
  return ""
101
101
 
102
102
  @abstractmethod
103
- def response_type_annotation(self, **kwargs) -> str:
104
- ...
103
+ def response_type_annotation(self, **kwargs) -> str: ...
105
104
 
106
105
  @abstractmethod
107
- def response_docstring_text(self, **kwargs) -> str:
108
- ...
106
+ def response_docstring_text(self, **kwargs) -> str: ...
109
107
 
110
108
  @abstractmethod
111
- def response_docstring_type(self, **kwargs) -> str:
112
- ...
109
+ def response_docstring_type(self, **kwargs) -> str: ...
113
110
 
114
111
  @property
115
112
  def description(self) -> str:
@@ -256,8 +256,10 @@ class EnumType(BaseType):
256
256
  "models",
257
257
  ImportType.LOCAL,
258
258
  alias="_models",
259
- typing_section=TypingSection.TYPING
260
- if kwargs.get("model_typing")
261
- else TypingSection.REGULAR,
259
+ typing_section=(
260
+ TypingSection.TYPING
261
+ if kwargs.get("model_typing")
262
+ else TypingSection.REGULAR
263
+ ),
262
264
  )
263
265
  return file_import
@@ -1,3 +1,4 @@
1
+ # pylint: disable=multiple-statements
1
2
  # -------------------------------------------------------------------------
2
3
  # Copyright (c) Microsoft Corporation. All rights reserved.
3
4
  # Licensed under the MIT License. See License.txt in the project root for
@@ -151,5 +152,4 @@ class LROOperationBase(OperationBase[LROResponseType]):
151
152
  return file_import
152
153
 
153
154
 
154
- class LROOperation(LROOperationBase[LROResponse]):
155
- ...
155
+ class LROOperation(LROOperationBase[LROResponse]): ...
@@ -165,9 +165,9 @@ class ModelType( # pylint: disable=abstract-method
165
165
  ]
166
166
  }
167
167
  if self.discriminator and self.discriminator_value:
168
- representation[
169
- f'"{self.discriminator.wire_name}"'
170
- ] = f'"{self.discriminator_value}"'
168
+ representation[f'"{self.discriminator.wire_name}"'] = (
169
+ f'"{self.discriminator_value}"'
170
+ )
171
171
 
172
172
  # once we've finished, we want to reset created_json_template_representation to false
173
173
  # so we can call it again
@@ -333,18 +333,22 @@ class GeneratedModelType(ModelType): # pylint: disable=abstract-method
333
333
  "models",
334
334
  ImportType.LOCAL,
335
335
  alias="_models",
336
- typing_section=TypingSection.TYPING
337
- if kwargs.get("model_typing")
338
- else TypingSection.REGULAR,
336
+ typing_section=(
337
+ TypingSection.TYPING
338
+ if kwargs.get("model_typing")
339
+ else TypingSection.REGULAR
340
+ ),
339
341
  )
340
342
  if self.is_form_data:
341
343
  file_import.add_submodule_import(
342
344
  relative_path,
343
345
  "_model_base",
344
346
  ImportType.LOCAL,
345
- typing_section=TypingSection.TYPING
346
- if kwargs.get("model_typing")
347
- else TypingSection.REGULAR,
347
+ typing_section=(
348
+ TypingSection.TYPING
349
+ if kwargs.get("model_typing")
350
+ else TypingSection.REGULAR
351
+ ),
348
352
  )
349
353
  return file_import
350
354
 
@@ -1,3 +1,4 @@
1
+ # pylint: disable=multiple-statements
1
2
  # -------------------------------------------------------------------------
2
3
  # Copyright (c) Microsoft Corporation. All rights reserved.
3
4
  # Licensed under the MIT License. See License.txt in the project root for
@@ -182,5 +183,4 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
182
183
  return file_import
183
184
 
184
185
 
185
- class PagingOperation(PagingOperationBase[PagingResponse]):
186
- ...
186
+ class PagingOperation(PagingOperationBase[PagingResponse]): ...
@@ -227,8 +227,7 @@ class _ParameterBase(
227
227
 
228
228
  @property
229
229
  @abc.abstractmethod
230
- def in_method_signature(self) -> bool:
231
- ...
230
+ def in_method_signature(self) -> bool: ...
232
231
 
233
232
  def method_signature(self, async_mode: bool) -> str:
234
233
  type_annot = self.type_annotation(async_mode=async_mode)
@@ -228,18 +228,26 @@ class NumberType(PrimitiveType): # pylint: disable=abstract-method
228
228
  @property
229
229
  def serialization_constraints(self) -> List[str]:
230
230
  validation_constraints = [
231
- f"maximum_ex={self.maximum}"
232
- if self.maximum is not None and self.exclusive_maximum
233
- else None,
234
- f"maximum={self.maximum}"
235
- if self.maximum is not None and not self.exclusive_maximum
236
- else None,
237
- f"minimum_ex={self.minimum}"
238
- if self.minimum is not None and self.exclusive_minimum
239
- else None,
240
- f"minimum={self.minimum}"
241
- if self.minimum is not None and not self.exclusive_minimum
242
- else None,
231
+ (
232
+ f"maximum_ex={self.maximum}"
233
+ if self.maximum is not None and self.exclusive_maximum
234
+ else None
235
+ ),
236
+ (
237
+ f"maximum={self.maximum}"
238
+ if self.maximum is not None and not self.exclusive_maximum
239
+ else None
240
+ ),
241
+ (
242
+ f"minimum_ex={self.minimum}"
243
+ if self.minimum is not None and self.exclusive_minimum
244
+ else None
245
+ ),
246
+ (
247
+ f"minimum={self.minimum}"
248
+ if self.minimum is not None and not self.exclusive_minimum
249
+ else None
250
+ ),
243
251
  f"multiple={self.multiple}" if self.multiple else None,
244
252
  ]
245
253
  return [x for x in validation_constraints if x is not None]
@@ -117,12 +117,14 @@ class RequestBuilderBase(BaseBuilder[ParameterListType, List["RequestBuilder"]])
117
117
  "typing", "Any", ImportType.STDLIB, typing_section=TypingSection.CONDITIONAL
118
118
  )
119
119
  file_import.add_msrest_import(
120
- relative_path="..."
121
- if (
122
- not self.code_model.options["builders_visibility"] == "embedded"
123
- and self.group_name
124
- )
125
- else "..",
120
+ relative_path=(
121
+ "..."
122
+ if (
123
+ not self.code_model.options["builders_visibility"] == "embedded"
124
+ and self.group_name
125
+ )
126
+ else ".."
127
+ ),
126
128
  msrest_import_type=MsrestImportType.Serializer,
127
129
  typing_section=TypingSection.REGULAR,
128
130
  )
@@ -137,8 +139,7 @@ class RequestBuilderBase(BaseBuilder[ParameterListType, List["RequestBuilder"]])
137
139
  @abstractmethod
138
140
  def parameter_list_type() -> (
139
141
  Callable[[Dict[str, Any], "CodeModel"], ParameterListType]
140
- ):
141
- ...
142
+ ): ...
142
143
 
143
144
  @classmethod
144
145
  def get_name(
@@ -524,7 +524,7 @@ class JinjaSerializer(ReaderAndWriter): # pylint: disable=abstract-method
524
524
  )
525
525
  if self.code_model.options.get("emit_cross_language_definition_file"):
526
526
  self.write_file(
527
- namespace_path / Path("apiview_mapping_python.json"),
527
+ Path("./apiview_mapping_python.json"),
528
528
  general_serializer.serialize_cross_language_definition_file(),
529
529
  )
530
530
 
@@ -1,4 +1,4 @@
1
- # pylint: disable=too-many-lines
1
+ # pylint: disable=too-many-lines,multiple-statements
2
2
  # -------------------------------------------------------------------------
3
3
  # Copyright (c) Microsoft Corporation. All rights reserved.
4
4
  # Licensed under the MIT License. See License.txt in the project root for
@@ -262,8 +262,7 @@ class _BuilderBaseSerializer(Generic[BuilderType]): # pylint: disable=abstract-
262
262
 
263
263
  @property
264
264
  @abstractmethod
265
- def _need_self_param(self) -> bool:
266
- ...
265
+ def _need_self_param(self) -> bool: ...
267
266
 
268
267
  @property
269
268
  @abstractmethod
@@ -378,8 +377,7 @@ class _BuilderBaseSerializer(Generic[BuilderType]): # pylint: disable=abstract-
378
377
 
379
378
  @property
380
379
  @abstractmethod
381
- def _json_response_template_name(self) -> str:
382
- ...
380
+ def _json_response_template_name(self) -> str: ...
383
381
 
384
382
  def _json_input_example_template(self, builder: BuilderType) -> List[str]:
385
383
  template: List[str] = []
@@ -525,12 +523,16 @@ class RequestBuilderSerializer(
525
523
  return self.parameter_serializer.pop_kwargs_from_signature(
526
524
  builder.parameters.kwargs_to_pop,
527
525
  check_kwarg_dict=True,
528
- pop_headers_kwarg=PopKwargType.CASE_INSENSITIVE
529
- if bool(builder.parameters.headers)
530
- else PopKwargType.NO,
531
- pop_params_kwarg=PopKwargType.CASE_INSENSITIVE
532
- if bool(builder.parameters.query)
533
- else PopKwargType.NO,
526
+ pop_headers_kwarg=(
527
+ PopKwargType.CASE_INSENSITIVE
528
+ if bool(builder.parameters.headers)
529
+ else PopKwargType.NO
530
+ ),
531
+ pop_params_kwarg=(
532
+ PopKwargType.CASE_INSENSITIVE
533
+ if bool(builder.parameters.query)
534
+ else PopKwargType.NO
535
+ ),
534
536
  )
535
537
 
536
538
  @staticmethod
@@ -711,16 +713,20 @@ class _OperationSerializer(
711
713
  kwargs = self.parameter_serializer.pop_kwargs_from_signature(
712
714
  kwargs_to_pop,
713
715
  check_kwarg_dict=True,
714
- pop_headers_kwarg=PopKwargType.CASE_INSENSITIVE
715
- if builder.has_kwargs_to_pop_with_default(
716
- kwargs_to_pop, ParameterLocation.HEADER # type: ignore
717
- )
718
- else PopKwargType.SIMPLE,
719
- pop_params_kwarg=PopKwargType.CASE_INSENSITIVE
720
- if builder.has_kwargs_to_pop_with_default(
721
- kwargs_to_pop, ParameterLocation.QUERY # type: ignore
722
- )
723
- else PopKwargType.SIMPLE,
716
+ pop_headers_kwarg=(
717
+ PopKwargType.CASE_INSENSITIVE
718
+ if builder.has_kwargs_to_pop_with_default(
719
+ kwargs_to_pop, ParameterLocation.HEADER # type: ignore
720
+ )
721
+ else PopKwargType.SIMPLE
722
+ ),
723
+ pop_params_kwarg=(
724
+ PopKwargType.CASE_INSENSITIVE
725
+ if builder.has_kwargs_to_pop_with_default(
726
+ kwargs_to_pop, ParameterLocation.QUERY # type: ignore
727
+ )
728
+ else PopKwargType.SIMPLE
729
+ ),
724
730
  check_client_input=not self.code_model.options["multiapi"],
725
731
  operation_name=f"('{builder.name}')" if builder.group_name == "" else "",
726
732
  )
@@ -1217,9 +1223,11 @@ class _OperationSerializer(
1217
1223
  retval.append(
1218
1224
  " raise HttpResponseError(response=response{}{})".format(
1219
1225
  error_model,
1220
- ", error_format=ARMErrorFormat"
1221
- if self.code_model.options["azure_arm"]
1222
- else "",
1226
+ (
1227
+ ", error_format=ARMErrorFormat"
1228
+ if self.code_model.options["azure_arm"]
1229
+ else ""
1230
+ ),
1223
1231
  )
1224
1232
  )
1225
1233
  return retval
@@ -1364,8 +1372,7 @@ class _OperationSerializer(
1364
1372
  return "await " if self.async_mode else ""
1365
1373
 
1366
1374
 
1367
- class OperationSerializer(_OperationSerializer[Operation]):
1368
- ...
1375
+ class OperationSerializer(_OperationSerializer[Operation]): ...
1369
1376
 
1370
1377
 
1371
1378
  ############################## PAGING OPERATIONS ##############################
@@ -1552,8 +1559,7 @@ class _PagingOperationSerializer(
1552
1559
  return retval
1553
1560
 
1554
1561
 
1555
- class PagingOperationSerializer(_PagingOperationSerializer[PagingOperation]):
1556
- ...
1562
+ class PagingOperationSerializer(_PagingOperationSerializer[PagingOperation]): ...
1557
1563
 
1558
1564
 
1559
1565
  ############################## LRO OPERATIONS ##############################
@@ -1682,12 +1688,16 @@ class _LROOperationSerializer(_OperationSerializer[LROOperationType]):
1682
1688
  retval.append(" if cls:")
1683
1689
  retval.append(
1684
1690
  " return cls(pipeline_response, {}, {}){}".format(
1685
- "deserialized"
1686
- if builder.lro_response and builder.lro_response.type
1687
- else "None",
1688
- "response_headers"
1689
- if builder.lro_response and builder.lro_response.headers
1690
- else "{}",
1691
+ (
1692
+ "deserialized"
1693
+ if builder.lro_response and builder.lro_response.type
1694
+ else "None"
1695
+ ),
1696
+ (
1697
+ "response_headers"
1698
+ if builder.lro_response and builder.lro_response.headers
1699
+ else "{}"
1700
+ ),
1691
1701
  " # type: ignore",
1692
1702
  )
1693
1703
  )
@@ -1696,8 +1706,7 @@ class _LROOperationSerializer(_OperationSerializer[LROOperationType]):
1696
1706
  return retval
1697
1707
 
1698
1708
 
1699
- class LROOperationSerializer(_LROOperationSerializer[LROOperation]):
1700
- ...
1709
+ class LROOperationSerializer(_LROOperationSerializer[LROOperation]): ...
1701
1710
 
1702
1711
 
1703
1712
  ############################## LRO PAGING OPERATIONS ##############################
@@ -206,9 +206,9 @@ class ClientSerializer:
206
206
  send_request_signature = self._send_request_signature()
207
207
  return utils.method_signature_and_response_type_annotation_template(
208
208
  method_signature=send_request_signature,
209
- response_type_annotation="Awaitable[AsyncHttpResponse]"
210
- if async_mode
211
- else "HttpResponse",
209
+ response_type_annotation=(
210
+ "Awaitable[AsyncHttpResponse]" if async_mode else "HttpResponse"
211
+ ),
212
212
  )
213
213
 
214
214
  def _example_make_call(self, async_mode: bool) -> List[str]:
@@ -66,11 +66,11 @@ def _json_serialize_imports(
66
66
  if name_imports:
67
67
  name_import_ordered_list = list(name_imports)
68
68
  name_import_ordered_list.sort(
69
- key=lambda e: _to_string(e) # type: ignore
70
- if isinstance(e, (list, tuple))
71
- else e
72
- if isinstance(e, str)
73
- else ""
69
+ key=lambda e: (
70
+ _to_string(e) # type: ignore
71
+ if isinstance(e, (list, tuple))
72
+ else e if isinstance(e, str) else ""
73
+ )
74
74
  )
75
75
  json_package_name_dictionary[package_name] = name_import_ordered_list
76
76
  json_import_type_dictionary[import_type_key] = json_package_name_dictionary
@@ -30,8 +30,7 @@ def _documentation_string(
30
30
 
31
31
  class _ModelSerializer(BaseSerializer, ABC):
32
32
  @abstractmethod
33
- def imports(self) -> FileImport:
34
- ...
33
+ def imports(self) -> FileImport: ...
35
34
 
36
35
  def serialize(self) -> str:
37
36
  # Generate the models
@@ -44,8 +43,7 @@ class _ModelSerializer(BaseSerializer, ABC):
44
43
  )
45
44
 
46
45
  @abstractmethod
47
- def declare_model(self, model: ModelType) -> str:
48
- ...
46
+ def declare_model(self, model: ModelType) -> str: ...
49
47
 
50
48
  @staticmethod
51
49
  def escape_dot(s: str):
@@ -13,7 +13,6 @@ import sys
13
13
  import logging
14
14
  import base64
15
15
  import re
16
- import copy
17
16
  import typing
18
17
  import enum
19
18
  import email.utils
@@ -347,7 +346,7 @@ _UNSET = object()
347
346
 
348
347
  class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object
349
348
  def __init__(self, data: typing.Dict[str, typing.Any]) -> None:
350
- self._data = copy.deepcopy(data)
349
+ self._data = data
351
350
 
352
351
  def __contains__(self, key: typing.Any) -> bool:
353
352
  return key in self._data
@@ -1143,9 +1143,11 @@ class M4Reformatter(
1143
1143
  "name": yaml_data["language"]["default"]["name"],
1144
1144
  "description": yaml_data["info"].get("description"),
1145
1145
  "parameters": parameters,
1146
- "url": update_client_url(yaml_data)
1147
- if yaml_data.get("globalParameters")
1148
- else "",
1146
+ "url": (
1147
+ update_client_url(yaml_data)
1148
+ if yaml_data.get("globalParameters")
1149
+ else ""
1150
+ ),
1149
1151
  }
1150
1152
 
1151
1153
  def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
@@ -69,9 +69,9 @@ def add_overload(
69
69
  content_type_param["inOverload"] = True
70
70
  content_type_param["inDocstring"] = True
71
71
  body_type_description = get_body_type_for_description(overload["bodyParameter"])
72
- content_type_param[
73
- "description"
74
- ] = f"Body Parameter content-type. Content type parameter for {body_type_description} body."
72
+ content_type_param["description"] = (
73
+ f"Body Parameter content-type. Content type parameter for {body_type_description} body."
74
+ )
75
75
  content_types = yaml_data["bodyParameter"]["contentTypes"]
76
76
  if body_type["type"] == "binary" and len(content_types) > 1:
77
77
  content_types = "'" + "', '".join(content_types) + "'"
@@ -110,9 +110,9 @@ def add_overloads_for_body_param(yaml_data: Dict[str, Any]) -> None:
110
110
  content_type_param["inOverload"] = False
111
111
  content_type_param["inOverriden"] = True
112
112
  content_type_param["inDocstring"] = True
113
- content_type_param[
114
- "clientDefaultValue"
115
- ] = None # make it none bc it will be overriden, we depend on default of overloads
113
+ content_type_param["clientDefaultValue"] = (
114
+ None # make it none bc it will be overriden, we depend on default of overloads
115
+ )
116
116
  content_type_param["optional"] = True
117
117
 
118
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.13.12",
3
+ "version": "6.13.13",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "main": "index.js",
6
6
  "repository": {
package/requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- black==22.12.0
1
+ black==24.4.0
2
2
  click==8.1.3
3
3
  docutils==0.19
4
4
  Jinja2==3.1.3