@autorest/python 6.38.1 → 6.39.0

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 (146) hide show
  1. package/README.md +2 -27
  2. package/autorest/codegen.py +0 -1
  3. package/autorest/jsonrpc/server.py +0 -3
  4. package/generator/build/lib/pygen/__init__.py +14 -23
  5. package/generator/build/lib/pygen/codegen/__init__.py +4 -4
  6. package/generator/build/lib/pygen/codegen/models/__init__.py +2 -2
  7. package/generator/build/lib/pygen/codegen/models/base.py +9 -12
  8. package/generator/build/lib/pygen/codegen/models/base_builder.py +4 -6
  9. package/generator/build/lib/pygen/codegen/models/client.py +61 -102
  10. package/generator/build/lib/pygen/codegen/models/code_model.py +29 -29
  11. package/generator/build/lib/pygen/codegen/models/combined_type.py +7 -7
  12. package/generator/build/lib/pygen/codegen/models/constant_type.py +4 -11
  13. package/generator/build/lib/pygen/codegen/models/credential_types.py +9 -11
  14. package/generator/build/lib/pygen/codegen/models/dictionary_type.py +7 -8
  15. package/generator/build/lib/pygen/codegen/models/enum_type.py +7 -7
  16. package/generator/build/lib/pygen/codegen/models/imports.py +24 -29
  17. package/generator/build/lib/pygen/codegen/models/list_type.py +15 -14
  18. package/generator/build/lib/pygen/codegen/models/lro_operation.py +6 -6
  19. package/generator/build/lib/pygen/codegen/models/lro_paging_operation.py +2 -2
  20. package/generator/build/lib/pygen/codegen/models/model_type.py +11 -11
  21. package/generator/build/lib/pygen/codegen/models/operation.py +26 -56
  22. package/generator/build/lib/pygen/codegen/models/operation_group.py +11 -22
  23. package/generator/build/lib/pygen/codegen/models/paging_operation.py +15 -19
  24. package/generator/build/lib/pygen/codegen/models/parameter.py +12 -21
  25. package/generator/build/lib/pygen/codegen/models/parameter_list.py +37 -39
  26. package/generator/build/lib/pygen/codegen/models/primitive_types.py +24 -18
  27. package/generator/build/lib/pygen/codegen/models/property.py +10 -10
  28. package/generator/build/lib/pygen/codegen/models/request_builder.py +7 -8
  29. package/generator/build/lib/pygen/codegen/models/request_builder_parameter.py +3 -3
  30. package/generator/build/lib/pygen/codegen/models/response.py +15 -40
  31. package/generator/build/lib/pygen/codegen/models/utils.py +2 -2
  32. package/generator/build/lib/pygen/codegen/serializers/__init__.py +26 -42
  33. package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +103 -100
  34. package/generator/build/lib/pygen/codegen/serializers/client_serializer.py +22 -25
  35. package/generator/build/lib/pygen/codegen/serializers/enum_serializer.py +2 -2
  36. package/generator/build/lib/pygen/codegen/serializers/general_serializer.py +49 -61
  37. package/generator/build/lib/pygen/codegen/serializers/import_serializer.py +6 -7
  38. package/generator/build/lib/pygen/codegen/serializers/model_init_serializer.py +1 -2
  39. package/generator/build/lib/pygen/codegen/serializers/model_serializer.py +15 -17
  40. package/generator/build/lib/pygen/codegen/serializers/operation_groups_serializer.py +3 -3
  41. package/generator/build/lib/pygen/codegen/serializers/operations_init_serializer.py +5 -6
  42. package/generator/build/lib/pygen/codegen/serializers/parameter_serializer.py +28 -18
  43. package/generator/build/lib/pygen/codegen/serializers/patch_serializer.py +1 -2
  44. package/generator/build/lib/pygen/codegen/serializers/request_builders_serializer.py +1 -2
  45. package/generator/build/lib/pygen/codegen/serializers/sample_serializer.py +9 -14
  46. package/generator/build/lib/pygen/codegen/serializers/test_serializer.py +7 -7
  47. package/generator/build/lib/pygen/codegen/serializers/utils.py +2 -2
  48. package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +30 -24
  49. package/generator/build/lib/pygen/codegen/templates/model_dpg.py.jinja2 +1 -1
  50. package/generator/build/lib/pygen/codegen/templates/operation_group.py.jinja2 +1 -11
  51. package/generator/build/lib/pygen/codegen/templates/operations_folder_init.py.jinja2 +1 -1
  52. package/generator/build/lib/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +2 -1
  53. package/generator/build/lib/pygen/codegen/templates/packaging_templates/dev_requirements.txt.jinja2 +1 -1
  54. package/generator/build/lib/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2 +13 -2
  55. package/generator/build/lib/pygen/codegen/templates/patch.py.jinja2 +1 -1
  56. package/generator/build/lib/pygen/codegen/templates/serialization.py.jinja2 +11 -13
  57. package/generator/build/lib/pygen/codegen/templates/utils.py.jinja2 +6 -6
  58. package/generator/build/lib/pygen/preprocess/__init__.py +47 -30
  59. package/generator/build/lib/pygen/preprocess/helpers.py +2 -2
  60. package/generator/build/lib/pygen/utils.py +6 -6
  61. package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
  62. package/generator/pygen/__init__.py +14 -23
  63. package/generator/pygen/codegen/__init__.py +4 -4
  64. package/generator/pygen/codegen/models/__init__.py +2 -2
  65. package/generator/pygen/codegen/models/base.py +9 -12
  66. package/generator/pygen/codegen/models/base_builder.py +4 -6
  67. package/generator/pygen/codegen/models/client.py +61 -102
  68. package/generator/pygen/codegen/models/code_model.py +29 -29
  69. package/generator/pygen/codegen/models/combined_type.py +7 -7
  70. package/generator/pygen/codegen/models/constant_type.py +4 -11
  71. package/generator/pygen/codegen/models/credential_types.py +9 -11
  72. package/generator/pygen/codegen/models/dictionary_type.py +7 -8
  73. package/generator/pygen/codegen/models/enum_type.py +7 -7
  74. package/generator/pygen/codegen/models/imports.py +24 -29
  75. package/generator/pygen/codegen/models/list_type.py +15 -14
  76. package/generator/pygen/codegen/models/lro_operation.py +6 -6
  77. package/generator/pygen/codegen/models/lro_paging_operation.py +2 -2
  78. package/generator/pygen/codegen/models/model_type.py +11 -11
  79. package/generator/pygen/codegen/models/operation.py +26 -56
  80. package/generator/pygen/codegen/models/operation_group.py +11 -22
  81. package/generator/pygen/codegen/models/paging_operation.py +15 -19
  82. package/generator/pygen/codegen/models/parameter.py +12 -21
  83. package/generator/pygen/codegen/models/parameter_list.py +37 -39
  84. package/generator/pygen/codegen/models/primitive_types.py +24 -18
  85. package/generator/pygen/codegen/models/property.py +10 -10
  86. package/generator/pygen/codegen/models/request_builder.py +7 -8
  87. package/generator/pygen/codegen/models/request_builder_parameter.py +3 -3
  88. package/generator/pygen/codegen/models/response.py +15 -40
  89. package/generator/pygen/codegen/models/utils.py +2 -2
  90. package/generator/pygen/codegen/serializers/__init__.py +26 -42
  91. package/generator/pygen/codegen/serializers/builder_serializer.py +103 -100
  92. package/generator/pygen/codegen/serializers/client_serializer.py +22 -25
  93. package/generator/pygen/codegen/serializers/enum_serializer.py +2 -2
  94. package/generator/pygen/codegen/serializers/general_serializer.py +49 -61
  95. package/generator/pygen/codegen/serializers/import_serializer.py +6 -7
  96. package/generator/pygen/codegen/serializers/model_init_serializer.py +1 -2
  97. package/generator/pygen/codegen/serializers/model_serializer.py +15 -17
  98. package/generator/pygen/codegen/serializers/operation_groups_serializer.py +3 -3
  99. package/generator/pygen/codegen/serializers/operations_init_serializer.py +5 -6
  100. package/generator/pygen/codegen/serializers/parameter_serializer.py +28 -18
  101. package/generator/pygen/codegen/serializers/patch_serializer.py +1 -2
  102. package/generator/pygen/codegen/serializers/request_builders_serializer.py +1 -2
  103. package/generator/pygen/codegen/serializers/sample_serializer.py +9 -14
  104. package/generator/pygen/codegen/serializers/test_serializer.py +7 -7
  105. package/generator/pygen/codegen/serializers/utils.py +2 -2
  106. package/generator/pygen/codegen/templates/model_base.py.jinja2 +30 -24
  107. package/generator/pygen/codegen/templates/model_dpg.py.jinja2 +1 -1
  108. package/generator/pygen/codegen/templates/operation_group.py.jinja2 +1 -11
  109. package/generator/pygen/codegen/templates/operations_folder_init.py.jinja2 +1 -1
  110. package/generator/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +2 -1
  111. package/generator/pygen/codegen/templates/packaging_templates/dev_requirements.txt.jinja2 +1 -1
  112. package/generator/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2 +13 -2
  113. package/generator/pygen/codegen/templates/patch.py.jinja2 +1 -1
  114. package/generator/pygen/codegen/templates/serialization.py.jinja2 +11 -13
  115. package/generator/pygen/codegen/templates/utils.py.jinja2 +6 -6
  116. package/generator/pygen/preprocess/__init__.py +47 -30
  117. package/generator/pygen/preprocess/helpers.py +2 -2
  118. package/generator/pygen/utils.py +6 -6
  119. package/generator/pygen.egg-info/SOURCES.txt +0 -2
  120. package/package.json +2 -2
  121. package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
  122. package/autorest/multiapi/__init__.py +0 -185
  123. package/autorest/multiapi/models/__init__.py +0 -16
  124. package/autorest/multiapi/models/client.py +0 -68
  125. package/autorest/multiapi/models/code_model.py +0 -142
  126. package/autorest/multiapi/models/config.py +0 -24
  127. package/autorest/multiapi/models/constant_global_parameter.py +0 -11
  128. package/autorest/multiapi/models/global_parameter.py +0 -34
  129. package/autorest/multiapi/models/global_parameters.py +0 -53
  130. package/autorest/multiapi/models/imports.py +0 -181
  131. package/autorest/multiapi/models/mixin_operation.py +0 -38
  132. package/autorest/multiapi/models/operation_group.py +0 -29
  133. package/autorest/multiapi/models/operation_mixin_group.py +0 -89
  134. package/autorest/multiapi/serializers/__init__.py +0 -145
  135. package/autorest/multiapi/serializers/import_serializer.py +0 -181
  136. package/autorest/multiapi/templates/multiapi_config.py.jinja2 +0 -89
  137. package/autorest/multiapi/templates/multiapi_init.py.jinja2 +0 -22
  138. package/autorest/multiapi/templates/multiapi_models.py.jinja2 +0 -9
  139. package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +0 -39
  140. package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +0 -163
  141. package/autorest/multiapi/templates/multiapi_version.py.jinja2 +0 -8
  142. package/autorest/multiapi/utils.py +0 -51
  143. package/generator/build/lib/pygen/codegen/serializers/metadata_serializer.py +0 -216
  144. package/generator/build/lib/pygen/codegen/templates/metadata.json.jinja2 +0 -167
  145. package/generator/pygen/codegen/serializers/metadata_serializer.py +0 -216
  146. package/generator/pygen/codegen/templates/metadata.json.jinja2 +0 -167
@@ -17,7 +17,6 @@ import re
17
17
  import sys
18
18
  import codecs
19
19
  from typing import (
20
- Dict,
21
20
  Any,
22
21
  cast,
23
22
  Optional,
@@ -27,7 +26,6 @@ from typing import (
27
26
  Mapping,
28
27
  Callable,
29
28
  MutableMapping,
30
- List,
31
29
  )
32
30
 
33
31
  try:
@@ -225,12 +223,12 @@ class Model:
225
223
  serialization and deserialization.
226
224
  """
227
225
 
228
- _subtype_map: Dict[str, Dict[str, Any]] = {}
229
- _attribute_map: Dict[str, Dict[str, Any]] = {}
230
- _validation: Dict[str, Dict[str, Any]] = {}
226
+ _subtype_map: dict[str, dict[str, Any]] = {}
227
+ _attribute_map: dict[str, dict[str, Any]] = {}
228
+ _validation: dict[str, dict[str, Any]] = {}
231
229
 
232
230
  def __init__(self, **kwargs: Any) -> None:
233
- self.additional_properties: Optional[Dict[str, Any]] = {}
231
+ self.additional_properties: Optional[dict[str, Any]] = {}
234
232
  for k in kwargs: # pylint: disable=consider-using-dict-items
235
233
  if k not in self._attribute_map:
236
234
  _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__)
@@ -307,7 +305,7 @@ class Model:
307
305
  def as_dict(
308
306
  self,
309
307
  keep_readonly: bool = True,
310
- key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer,
308
+ key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer,
311
309
  **kwargs: Any
312
310
  ) -> JSON:
313
311
  """Return a dict that can be serialized using json.dump.
@@ -376,7 +374,7 @@ class Model:
376
374
  def from_dict(
377
375
  cls,
378
376
  data: Any,
379
- key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None,
377
+ key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None,
380
378
  content_type: Optional[str] = None,
381
379
  ) -> Self:
382
380
  """Parse a dict using given key extractor return a model.
@@ -410,7 +408,7 @@ class Model:
410
408
  return {}
411
409
  result = dict(cls._subtype_map[key])
412
410
  for valuetype in cls._subtype_map[key].values():
413
- result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access
411
+ result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access
414
412
  return result
415
413
 
416
414
  @classmethod
@@ -524,7 +522,7 @@ class Serializer: # pylint: disable=too-many-public-methods
524
522
  "[]": self.serialize_iter,
525
523
  "{}": self.serialize_dict,
526
524
  }
527
- self.dependencies: Dict[str, type] = dict(classes) if classes else {}
525
+ self.dependencies: dict[str, type] = dict(classes) if classes else {}
528
526
  self.key_transformer = full_restapi_key_transformer
529
527
  self.client_side_validation = True
530
528
 
@@ -575,7 +573,7 @@ class Serializer: # pylint: disable=too-many-public-methods
575
573
 
576
574
  if attr_name == "additional_properties" and attr_desc["key"] == "":
577
575
  if target_obj.additional_properties is not None:
578
- serialized.update(target_obj.additional_properties)
576
+ serialized |= target_obj.additional_properties
579
577
  continue
580
578
  try:
581
579
 
@@ -1180,7 +1178,7 @@ def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argumen
1180
1178
 
1181
1179
  while "." in key:
1182
1180
  # Need the cast, as for some reasons "split" is typed as list[str | Any]
1183
- dict_keys = cast(List[str], _FLATTEN.split(key))
1181
+ dict_keys = cast(list[str], _FLATTEN.split(key))
1184
1182
  if len(dict_keys) == 1:
1185
1183
  key = _decode_attribute_map_key(dict_keys[0])
1186
1184
  break
@@ -1382,7 +1380,7 @@ class Deserializer:
1382
1380
  "duration": (isodate.Duration, datetime.timedelta),
1383
1381
  "iso-8601": (datetime.datetime),
1384
1382
  }
1385
- self.dependencies: Dict[str, type] = dict(classes) if classes else {}
1383
+ self.dependencies: dict[str, type] = dict(classes) if classes else {}
1386
1384
  self.key_extractors = [rest_key_extractor, xml_key_extractor]
1387
1385
  # Additional properties only works if the "rest_key_extractor" is used to
1388
1386
  # extract the keys. Making it to work whatever the key extractor is too much
@@ -66,9 +66,9 @@ FileType = Union[
66
66
  # file (or bytes)
67
67
  FileContent,
68
68
  # (filename, file (or bytes))
69
- Tuple[Optional[str], FileContent],
69
+ tuple[Optional[str], FileContent],
70
70
  # (filename, file (or bytes), content_type)
71
- Tuple[Optional[str], FileContent, Optional[str]],
71
+ tuple[Optional[str], FileContent, Optional[str]],
72
72
  ]
73
73
 
74
74
  def serialize_multipart_data_entry(data_entry: Any) -> Any:
@@ -77,10 +77,10 @@ def serialize_multipart_data_entry(data_entry: Any) -> Any:
77
77
  return data_entry
78
78
 
79
79
  def prepare_multipart_form_data(
80
- body: Mapping[str, Any], multipart_fields: List[str], data_fields: List[str]
81
- ) -> Tuple[List[FileType], Dict[str, Any]]:
82
- files: List[FileType] = []
83
- data: Dict[str, Any] = {}
80
+ body: Mapping[str, Any], multipart_fields: list[str], data_fields: list[str]
81
+ ) -> tuple[list[FileType], dict[str, Any]]:
82
+ files: list[FileType] = []
83
+ data: dict[str, Any] = {}
84
84
  for multipart_field in multipart_fields:
85
85
  multipart_entry = body.get(multipart_field)
86
86
  if isinstance(multipart_entry, list):
@@ -5,7 +5,7 @@
5
5
  # --------------------------------------------------------------------------
6
6
  """The preprocessing autorest plugin."""
7
7
  import copy
8
- from typing import Callable, Dict, Any, List, Optional
8
+ from typing import Callable, Any, Optional
9
9
 
10
10
  from ..utils import to_snake_case, extract_original_name
11
11
  from .helpers import (
@@ -26,8 +26,8 @@ from ..utils import (
26
26
 
27
27
 
28
28
  def update_overload_section(
29
- overload: Dict[str, Any],
30
- yaml_data: Dict[str, Any],
29
+ overload: dict[str, Any],
30
+ yaml_data: dict[str, Any],
31
31
  section: str,
32
32
  ):
33
33
  try:
@@ -42,7 +42,7 @@ def update_overload_section(
42
42
  raise ValueError(overload["name"]) from exc
43
43
 
44
44
 
45
- def add_overload(yaml_data: Dict[str, Any], body_type: Dict[str, Any], for_flatten_params=False):
45
+ def add_overload(yaml_data: dict[str, Any], body_type: dict[str, Any], for_flatten_params=False):
46
46
  overload = copy.deepcopy(yaml_data)
47
47
  overload["isOverload"] = True
48
48
  overload["bodyParameter"]["type"] = body_type
@@ -80,7 +80,7 @@ def add_overload(yaml_data: Dict[str, Any], body_type: Dict[str, Any], for_flatt
80
80
  return overload
81
81
 
82
82
 
83
- def add_overloads_for_body_param(yaml_data: Dict[str, Any]) -> None:
83
+ def add_overloads_for_body_param(yaml_data: dict[str, Any]) -> None:
84
84
  """If we added a body parameter type, add overloads for that type"""
85
85
  body_parameter = yaml_data["bodyParameter"]
86
86
  if not (
@@ -121,7 +121,7 @@ def update_operation_group_class_name(prefix: str, class_name: str) -> str:
121
121
  return class_name + "Operations"
122
122
 
123
123
 
124
- def update_paging_response(yaml_data: Dict[str, Any]) -> None:
124
+ def update_paging_response(yaml_data: dict[str, Any]) -> None:
125
125
  yaml_data["discriminator"] = "paging"
126
126
 
127
127
 
@@ -148,23 +148,35 @@ HEADERS_CONVERT_IN_METHOD = {
148
148
  },
149
149
  },
150
150
  }
151
+ CLOUD_SETTING = {
152
+ "optional": True,
153
+ "description": "The cloud setting for which to get the ARM endpoint.",
154
+ "clientName": "cloud_setting",
155
+ "implementation": "Client",
156
+ "location": "keyword",
157
+ "type": {
158
+ "type": "sdkcore",
159
+ "name": "AzureClouds",
160
+ "isTypingOnly": True,
161
+ },
162
+ }
151
163
 
152
164
 
153
- def get_wire_name_lower(parameter: Dict[str, Any]) -> str:
165
+ def get_wire_name_lower(parameter: dict[str, Any]) -> str:
154
166
  return (parameter.get("wireName") or "").lower()
155
167
 
156
168
 
157
- def headers_convert(yaml_data: Dict[str, Any], replace_data: Any) -> None:
169
+ def headers_convert(yaml_data: dict[str, Any], replace_data: Any) -> None:
158
170
  if isinstance(replace_data, dict):
159
171
  for k, v in replace_data.items():
160
172
  yaml_data[k] = v
161
173
 
162
174
 
163
- def has_json_content_type(yaml_data: Dict[str, Any]) -> bool:
175
+ def has_json_content_type(yaml_data: dict[str, Any]) -> bool:
164
176
  return any(ct for ct in yaml_data.get("contentTypes", []) if JSON_REGEXP.match(ct))
165
177
 
166
178
 
167
- def has_multi_part_content_type(yaml_data: Dict[str, Any]) -> bool:
179
+ def has_multi_part_content_type(yaml_data: dict[str, Any]) -> bool:
168
180
  return any(ct for ct in yaml_data.get("contentTypes", []) if ct == "multipart/form-data")
169
181
 
170
182
 
@@ -189,8 +201,8 @@ class PreProcessPlugin(YamlUpdatePlugin):
189
201
 
190
202
  def add_body_param_type(
191
203
  self,
192
- code_model: Dict[str, Any],
193
- body_parameter: Dict[str, Any],
204
+ code_model: dict[str, Any],
205
+ body_parameter: dict[str, Any],
194
206
  ):
195
207
  # only add overload for special content type
196
208
  if ( # pylint: disable=too-many-boolean-expressions
@@ -231,7 +243,7 @@ class PreProcessPlugin(YamlUpdatePlugin):
231
243
  return name_prefix + name + pad_type
232
244
  return name_prefix + name
233
245
 
234
- def update_types(self, yaml_data: List[Dict[str, Any]]) -> None:
246
+ def update_types(self, yaml_data: list[dict[str, Any]]) -> None:
235
247
  for type in yaml_data:
236
248
  for property in type.get("properties", []):
237
249
  property["description"] = update_description(property.get("description", ""))
@@ -268,8 +280,9 @@ class PreProcessPlugin(YamlUpdatePlugin):
268
280
  for v in HEADERS_CONVERT_IN_METHOD.values():
269
281
  if isinstance(v, dict) and "type" in v:
270
282
  yaml_data.append(v["type"])
283
+ yaml_data.append(CLOUD_SETTING["type"]) # type: ignore
271
284
 
272
- def update_client(self, yaml_data: Dict[str, Any]) -> None:
285
+ def update_client(self, yaml_data: dict[str, Any]) -> None:
273
286
  yaml_data["description"] = update_description(yaml_data["description"], default_description=yaml_data["name"])
274
287
  yaml_data["legacyFilename"] = to_snake_case(yaml_data["name"].replace(" ", "_"))
275
288
  parameters = yaml_data["parameters"]
@@ -325,7 +338,11 @@ class PreProcessPlugin(YamlUpdatePlugin):
325
338
  o["hasEtag"] = True
326
339
  yaml_data["hasEtag"] = True
327
340
 
328
- def get_operation_updater(self, yaml_data: Dict[str, Any]) -> Callable[[Dict[str, Any], Dict[str, Any]], None]:
341
+ # add client signature cloud_setting for arm
342
+ if self.azure_arm and yaml_data["parameters"]:
343
+ yaml_data["parameters"].append(CLOUD_SETTING)
344
+
345
+ def get_operation_updater(self, yaml_data: dict[str, Any]) -> Callable[[dict[str, Any], dict[str, Any]], None]:
329
346
  if yaml_data["discriminator"] == "lropaging":
330
347
  return self.update_lro_paging_operation
331
348
  if yaml_data["discriminator"] == "lro":
@@ -334,7 +351,7 @@ class PreProcessPlugin(YamlUpdatePlugin):
334
351
  return self.update_paging_operation
335
352
  return self.update_operation
336
353
 
337
- def update_parameter(self, yaml_data: Dict[str, Any]) -> None:
354
+ def update_parameter(self, yaml_data: dict[str, Any]) -> None:
338
355
  yaml_data["description"] = update_description(yaml_data.get("description", ""))
339
356
  if not (yaml_data["location"] == "header" and yaml_data["clientName"] in ("content_type", "accept")):
340
357
  yaml_data["clientName"] = self.pad_reserved_words(yaml_data["clientName"].lower(), PadType.PARAMETER)
@@ -358,8 +375,8 @@ class PreProcessPlugin(YamlUpdatePlugin):
358
375
 
359
376
  def update_operation(
360
377
  self,
361
- code_model: Dict[str, Any],
362
- yaml_data: Dict[str, Any],
378
+ code_model: dict[str, Any],
379
+ yaml_data: dict[str, Any],
363
380
  *,
364
381
  is_overload: bool = False,
365
382
  ) -> None:
@@ -390,7 +407,7 @@ class PreProcessPlugin(YamlUpdatePlugin):
390
407
  self.add_body_param_type(code_model, body_parameter)
391
408
  add_overloads_for_body_param(yaml_data)
392
409
 
393
- def _update_lro_operation_helper(self, yaml_data: Dict[str, Any]) -> None:
410
+ def _update_lro_operation_helper(self, yaml_data: dict[str, Any]) -> None:
394
411
  for response in yaml_data.get("responses", []):
395
412
  response["discriminator"] = "lro"
396
413
  response["pollerSync"] = response.get("pollerSync") or "azure.core.polling.LROPoller"
@@ -410,10 +427,10 @@ class PreProcessPlugin(YamlUpdatePlugin):
410
427
 
411
428
  def update_lro_paging_operation(
412
429
  self,
413
- code_model: Dict[str, Any],
414
- yaml_data: Dict[str, Any],
430
+ code_model: dict[str, Any],
431
+ yaml_data: dict[str, Any],
415
432
  is_overload: bool = False,
416
- item_type: Optional[Dict[str, Any]] = None,
433
+ item_type: Optional[dict[str, Any]] = None,
417
434
  ) -> None:
418
435
  self.update_lro_operation(code_model, yaml_data, is_overload=is_overload)
419
436
  self.update_paging_operation(code_model, yaml_data, is_overload=is_overload, item_type=item_type)
@@ -430,11 +447,11 @@ class PreProcessPlugin(YamlUpdatePlugin):
430
447
 
431
448
  def update_lro_operation(
432
449
  self,
433
- code_model: Dict[str, Any],
434
- yaml_data: Dict[str, Any],
450
+ code_model: dict[str, Any],
451
+ yaml_data: dict[str, Any],
435
452
  is_overload: bool = False,
436
453
  ) -> None:
437
- def convert_initial_operation_response_type(data: Dict[str, Any]) -> None:
454
+ def convert_initial_operation_response_type(data: dict[str, Any]) -> None:
438
455
  for response in data.get("responses", []):
439
456
  response["type"] = KNOWN_TYPES["binary"]
440
457
 
@@ -449,10 +466,10 @@ class PreProcessPlugin(YamlUpdatePlugin):
449
466
 
450
467
  def update_paging_operation(
451
468
  self,
452
- code_model: Dict[str, Any],
453
- yaml_data: Dict[str, Any],
469
+ code_model: dict[str, Any],
470
+ yaml_data: dict[str, Any],
454
471
  is_overload: bool = False,
455
- item_type: Optional[Dict[str, Any]] = None,
472
+ item_type: Optional[dict[str, Any]] = None,
456
473
  ) -> None:
457
474
  self.update_operation(code_model, yaml_data, is_overload=is_overload)
458
475
  item_type = item_type or yaml_data["itemType"]["elementType"]
@@ -470,7 +487,7 @@ class PreProcessPlugin(YamlUpdatePlugin):
470
487
  for overload in yaml_data.get("overloads", []):
471
488
  self.update_paging_operation(code_model, overload, is_overload=True, item_type=item_type)
472
489
 
473
- def update_operation_groups(self, code_model: Dict[str, Any], client: Dict[str, Any]) -> None:
490
+ def update_operation_groups(self, code_model: dict[str, Any], client: dict[str, Any]) -> None:
474
491
  operation_groups_yaml_data = client.get("operationGroups", [])
475
492
  for operation_group in operation_groups_yaml_data:
476
493
  operation_group["identifyName"] = self.pad_reserved_words(
@@ -491,7 +508,7 @@ class PreProcessPlugin(YamlUpdatePlugin):
491
508
  if operation_group.get("operationGroups"):
492
509
  self.update_operation_groups(code_model, operation_group)
493
510
 
494
- def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
511
+ def update_yaml(self, yaml_data: dict[str, Any]) -> None:
495
512
  """Convert in place the YAML str."""
496
513
  self.update_types(yaml_data["types"])
497
514
  yaml_data["types"] += KNOWN_TYPES.values()
@@ -4,14 +4,14 @@
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
6
  import re
7
- from typing import Any, Dict
7
+ from typing import Any
8
8
  from .python_mappings import (
9
9
  REDEFINED_BUILTINS,
10
10
  BUILTIN_PACKAGES,
11
11
  )
12
12
 
13
13
 
14
- def add_redefined_builtin_info(name: str, yaml_data: Dict[str, Any]) -> None:
14
+ def add_redefined_builtin_info(name: str, yaml_data: dict[str, Any]) -> None:
15
15
  if name in REDEFINED_BUILTINS:
16
16
  yaml_data["pylintDisable"] = "redefined-builtin"
17
17
 
@@ -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, Tuple, List
6
+ from typing import Any
7
7
  import re
8
8
  import argparse
9
9
 
@@ -12,7 +12,7 @@ TYPESPEC_PACKAGE_MODE = ["azure-mgmt", "azure-dataplane", "generic"]
12
12
  VALID_PACKAGE_MODE = SWAGGER_PACKAGE_MODE + TYPESPEC_PACKAGE_MODE
13
13
 
14
14
 
15
- def update_enum_value(name: str, value: Any, description: str, enum_type: Dict[str, Any]) -> Dict[str, Any]:
15
+ def update_enum_value(name: str, value: Any, description: str, enum_type: dict[str, Any]) -> dict[str, Any]:
16
16
  return {
17
17
  "name": name,
18
18
  "type": "enumvalue",
@@ -49,7 +49,7 @@ def to_snake_case(name: str) -> str:
49
49
 
50
50
  def parse_args(
51
51
  need_tsp_file: bool = True,
52
- ) -> Tuple[argparse.Namespace, Dict[str, Any]]:
52
+ ) -> tuple[argparse.Namespace, dict[str, Any]]:
53
53
  parser = argparse.ArgumentParser(
54
54
  description="Run mypy against target folder. Add a local custom plugin to the path prior to execution. "
55
55
  )
@@ -92,7 +92,7 @@ def parse_args(
92
92
  return args, unknown_args_ret
93
93
 
94
94
 
95
- def get_body_type_for_description(body_parameter: Dict[str, Any]) -> str:
95
+ def get_body_type_for_description(body_parameter: dict[str, Any]) -> str:
96
96
  if body_parameter["type"]["type"] == "binary":
97
97
  return "binary"
98
98
  if body_parameter["type"]["type"] == "string":
@@ -101,7 +101,7 @@ def get_body_type_for_description(body_parameter: Dict[str, Any]) -> str:
101
101
 
102
102
 
103
103
  # used if we want to get a string / binary type etc
104
- KNOWN_TYPES: Dict[str, Dict[str, Any]] = {
104
+ KNOWN_TYPES: dict[str, dict[str, Any]] = {
105
105
  "string": {"type": "string"},
106
106
  "binary": {"type": "binary"},
107
107
  "anydict": {"type": "dict", "elementType": {"type": "any"}},
@@ -118,7 +118,7 @@ def build_policies(
118
118
  *,
119
119
  is_azure_flavor: bool = False,
120
120
  tracing: bool = True,
121
- ) -> List[str]:
121
+ ) -> list[str]:
122
122
  if is_azure_flavor:
123
123
  # for Azure
124
124
  async_prefix = "Async" if async_mode else ""
@@ -8,7 +8,7 @@ import logging
8
8
  from pathlib import Path
9
9
  import json
10
10
  from abc import ABC, abstractmethod
11
- from typing import Any, Dict, Iterator, Optional, Union, List
11
+ from typing import Any, Iterator, Optional, Union
12
12
 
13
13
  import yaml
14
14
  from .utils import TYPESPEC_PACKAGE_MODE, VALID_PACKAGE_MODE
@@ -33,7 +33,6 @@ class OptionsDict(MutableMapping):
33
33
  "head-as-boolean": True,
34
34
  "keep-version-file": False,
35
35
  "low-level-client": False,
36
- "multiapi": False,
37
36
  "no-async": False,
38
37
  "no-namespace-folders": False,
39
38
  "polymorphic-examples": 5,
@@ -42,11 +41,11 @@ class OptionsDict(MutableMapping):
42
41
  "generation-subdir": None, # subdirectory to generate the code in
43
42
  }
44
43
 
45
- def __init__(self, options: Optional[Dict[str, Any]] = None) -> None:
44
+ def __init__(self, options: Optional[dict[str, Any]] = None) -> None:
46
45
  self._data = options.copy() if options else {}
47
46
  self._validate_combinations()
48
47
 
49
- def __getitem__(self, key: str) -> Any: # pylint: disable=too-many-return-statements
48
+ def __getitem__(self, key: str) -> Any: # pylint: disable=too-many-return-statements
50
49
  if key == "head-as-boolean" and self.get("azure-arm"):
51
50
  # override to always true if azure-arm is set
52
51
  return True
@@ -109,7 +108,12 @@ class OptionsDict(MutableMapping):
109
108
  if key == "combine-operation-files":
110
109
  return self.get("version-tolerant")
111
110
  if key == "package-pprint-name":
112
- return " ".join([i.capitalize() for i in str(self.get("package-name", "")).split("-")])
111
+ package_names = self.get("package-name", "").split("-")
112
+ return (
113
+ (package_names[-1].capitalize() + " Management")
114
+ if self.get("azure-arm")
115
+ else " ".join([i.capitalize() for i in package_names])
116
+ )
113
117
  if key == "builders-visibility":
114
118
  # Default to public if low-level client is not set, otherwise embedded
115
119
  return "embedded" if not self.get("low-level-client") else "public"
@@ -143,16 +147,6 @@ class OptionsDict(MutableMapping):
143
147
  "If you want operation files, pass in flag --show-operations"
144
148
  )
145
149
 
146
- if self.get("multiapi") and self.get("version-tolerant"):
147
- raise ValueError(
148
- "Can not currently generate version tolerant multiapi SDKs. "
149
- "We are working on creating a new multiapi SDK for version tolerant and it is not available yet."
150
- )
151
-
152
- # If multiapi, do not generate default pyproject.toml
153
- if self.get("multiapi"):
154
- self["keep-setup-py"] = True
155
-
156
150
  if self.get("client-side-validation") and self.get("version-tolerant"):
157
151
  raise ValueError("Can not generate version tolerant with --client-side-validation. ")
158
152
 
@@ -200,7 +194,7 @@ class OptionsDict(MutableMapping):
200
194
  for key in self.DEFAULTS:
201
195
  if key not in all_keys:
202
196
  all_keys.add(key)
203
- all_keys.update(self.DEFAULTS.keys())
197
+ all_keys |= self.DEFAULTS.keys()
204
198
  return KeysView({key: None for key in all_keys})
205
199
 
206
200
  def values(self) -> ValuesView[Any]:
@@ -213,7 +207,7 @@ class OptionsDict(MutableMapping):
213
207
  class ReaderAndWriter:
214
208
  def __init__(self, *, output_folder: Union[str, Path], **kwargs: Any) -> None:
215
209
  self.output_folder = Path(output_folder)
216
- self._list_file: List[str] = []
210
+ self._list_file: list[str] = []
217
211
  try:
218
212
  with open(
219
213
  Path(self.output_folder) / Path("..") / Path("python.json"),
@@ -229,9 +223,6 @@ class ReaderAndWriter:
229
223
  _LOGGER.warning("Loading python.json file. This behavior will be depreacted")
230
224
  self.options.update(python_json)
231
225
 
232
- def get_output_folder(self) -> Path:
233
- return self.output_folder
234
-
235
226
  def read_file(self, path: Union[str, Path]) -> str:
236
227
  """Directly reading from disk"""
237
228
  # make path relative to output folder
@@ -257,7 +248,7 @@ class ReaderAndWriter:
257
248
  except FileNotFoundError:
258
249
  pass
259
250
 
260
- def list_file(self) -> List[str]:
251
+ def list_file(self) -> list[str]:
261
252
  return [str(f.relative_to(self.output_folder)) for f in self.output_folder.glob("**/*") if f.is_file()]
262
253
 
263
254
 
@@ -281,7 +272,7 @@ class Plugin(ReaderAndWriter, ABC):
281
272
  class YamlUpdatePlugin(Plugin):
282
273
  """A plugin that update the YAML as input."""
283
274
 
284
- def get_yaml(self) -> Dict[str, Any]:
275
+ def get_yaml(self) -> dict[str, Any]:
285
276
  # tsp file doesn't have to be relative to output folder
286
277
  with open(self.options["tsp_file"], "r", encoding="utf-8-sig") as fd:
287
278
  return yaml.safe_load(fd.read())
@@ -302,7 +293,7 @@ class YamlUpdatePlugin(Plugin):
302
293
  return True
303
294
 
304
295
  @abstractmethod
305
- def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
296
+ def update_yaml(self, yaml_data: dict[str, Any]) -> None:
306
297
  """The code-model-v4-no-tags yaml model tree.
307
298
 
308
299
  :rtype: updated yaml
@@ -4,7 +4,7 @@
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
6
  import logging
7
- from typing import Dict, Any
7
+ from typing import Any
8
8
  import yaml
9
9
 
10
10
 
@@ -20,7 +20,7 @@ _LOGGER = logging.getLogger(__name__)
20
20
  class CodeGenerator(Plugin):
21
21
 
22
22
  @staticmethod
23
- def sort_exceptions(yaml_data: Dict[str, Any]) -> None:
23
+ def sort_exceptions(yaml_data: dict[str, Any]) -> None:
24
24
  for client in yaml_data["clients"]:
25
25
  for group in client.get("operationGroups", []):
26
26
  for operation in group.get("operations", []):
@@ -37,7 +37,7 @@ class CodeGenerator(Plugin):
37
37
  )
38
38
 
39
39
  @staticmethod
40
- def remove_cloud_errors(yaml_data: Dict[str, Any]) -> None:
40
+ def remove_cloud_errors(yaml_data: dict[str, Any]) -> None:
41
41
  for client in yaml_data["clients"]:
42
42
  for group in client.get("operationGroups", []):
43
43
  for operation in group.get("operations", []):
@@ -60,7 +60,7 @@ class CodeGenerator(Plugin):
60
60
  del yaml_data["schemas"]["objects"][i]
61
61
  break
62
62
 
63
- def get_yaml(self) -> Dict[str, Any]:
63
+ def get_yaml(self) -> dict[str, Any]:
64
64
  # tsp file doesn't have to be relative to output folder
65
65
  with open(self.options["tsp_file"], "r", encoding="utf-8-sig") as fd:
66
66
  return yaml.safe_load(fd.read())
@@ -4,7 +4,7 @@
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
6
  import logging
7
- from typing import Any, Dict, Union, Optional
7
+ from typing import Any, Union, Optional
8
8
  from .base import BaseModel
9
9
  from .base_builder import BaseBuilder, ParameterListType
10
10
  from .code_model import CodeModel
@@ -155,7 +155,7 @@ TYPE_TO_OBJECT = {
155
155
  _LOGGER = logging.getLogger(__name__)
156
156
 
157
157
 
158
- def build_type(yaml_data: Dict[str, Any], code_model: CodeModel) -> BaseType:
158
+ def build_type(yaml_data: dict[str, Any], code_model: CodeModel) -> BaseType:
159
159
  yaml_id = id(yaml_data)
160
160
  try:
161
161
  return code_model.lookup_type(yaml_id)
@@ -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, TYPE_CHECKING, List, Optional
6
+ from typing import Any, TYPE_CHECKING, Optional
7
7
  from abc import ABC, abstractmethod
8
8
  from .imports import FileImport
9
9
 
@@ -20,7 +20,7 @@ class BaseModel:
20
20
  :type yaml_data: dict[str, Any]
21
21
  """
22
22
 
23
- def __init__(self, yaml_data: Dict[str, Any], code_model: "CodeModel") -> None:
23
+ def __init__(self, yaml_data: dict[str, Any], code_model: "CodeModel") -> None:
24
24
  self.yaml_data = yaml_data
25
25
  self.code_model = code_model
26
26
 
@@ -39,21 +39,18 @@ class BaseType(BaseModel, ABC): # pylint: disable=too-many-public-methods
39
39
  :type yaml_data: dict[str, Any]
40
40
  """
41
41
 
42
- def __init__(self, yaml_data: Dict[str, Any], code_model: "CodeModel") -> None:
42
+ def __init__(self, yaml_data: dict[str, Any], code_model: "CodeModel") -> None:
43
43
  super().__init__(yaml_data, code_model)
44
44
  self.type = yaml_data["type"] # the type discriminator
45
- self.api_versions: List[str] = yaml_data.get("apiVersions", []) # api versions this type is in.
45
+ self.api_versions: list[str] = yaml_data.get("apiVersions", []) # api versions this type is in.
46
46
 
47
47
  @classmethod
48
- def from_yaml(cls, yaml_data: Dict[str, Any], code_model: "CodeModel") -> "BaseType":
48
+ def from_yaml(cls, yaml_data: dict[str, Any], code_model: "CodeModel") -> "BaseType":
49
49
  return cls(yaml_data=yaml_data, code_model=code_model)
50
50
 
51
51
  def imports(self, **kwargs) -> FileImport: # pylint: disable=unused-argument
52
52
  return FileImport(self.code_model)
53
53
 
54
- def imports_for_multiapi(self, **kwargs: Any) -> FileImport:
55
- return self.imports(**kwargs)
56
-
57
54
  def imports_for_sample(self) -> FileImport:
58
55
  return FileImport(self.code_model)
59
56
 
@@ -62,7 +59,7 @@ class BaseType(BaseModel, ABC): # pylint: disable=too-many-public-methods
62
59
  return repr(value)
63
60
 
64
61
  @property
65
- def xml_metadata(self) -> Dict[str, Any]:
62
+ def xml_metadata(self) -> dict[str, Any]:
66
63
  """XML metadata for the type, if the type has it."""
67
64
  return self.yaml_data.get("xmlMetadata", {})
68
65
 
@@ -132,7 +129,7 @@ class BaseType(BaseModel, ABC): # pylint: disable=too-many-public-methods
132
129
  """
133
130
 
134
131
  @property
135
- def validation(self) -> Optional[Dict[str, Any]]:
132
+ def validation(self) -> Optional[dict[str, Any]]:
136
133
  """Whether there's any validation constraints on this type.
137
134
 
138
135
  Even though we generate validation maps if there are validation constraints,
@@ -162,7 +159,7 @@ class BaseType(BaseModel, ABC): # pylint: disable=too-many-public-methods
162
159
  """Template of what this schema would look like as JSON input"""
163
160
 
164
161
  def get_polymorphic_subtypes(
165
- self, polymorphic_subtypes: List["ModelType"] # pylint: disable=unused-argument
162
+ self, polymorphic_subtypes: list["ModelType"] # pylint: disable=unused-argument
166
163
  ) -> None:
167
164
  return None
168
165
 
@@ -172,7 +169,7 @@ class BaseType(BaseModel, ABC): # pylint: disable=too-many-public-methods
172
169
  """Template of what an instance check of a variable for this type would look like"""
173
170
 
174
171
  @property
175
- def serialization_constraints(self) -> List[str]:
172
+ def serialization_constraints(self) -> list[str]:
176
173
  """Whether there are any serialization constraints when serializing this type."""
177
174
  return []
178
175