@autorest/python 6.13.16 → 6.13.17

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 (73) hide show
  1. package/autorest/__init__.py +4 -12
  2. package/autorest/_utils.py +5 -20
  3. package/autorest/black/__init__.py +1 -3
  4. package/autorest/codegen/__init__.py +29 -96
  5. package/autorest/codegen/models/__init__.py +1 -3
  6. package/autorest/codegen/models/base.py +2 -6
  7. package/autorest/codegen/models/base_builder.py +2 -6
  8. package/autorest/codegen/models/client.py +24 -86
  9. package/autorest/codegen/models/code_model.py +13 -53
  10. package/autorest/codegen/models/combined_type.py +3 -9
  11. package/autorest/codegen/models/constant_type.py +4 -14
  12. package/autorest/codegen/models/credential_types.py +11 -35
  13. package/autorest/codegen/models/dictionary_type.py +4 -12
  14. package/autorest/codegen/models/enum_type.py +10 -31
  15. package/autorest/codegen/models/imports.py +15 -41
  16. package/autorest/codegen/models/list_type.py +7 -23
  17. package/autorest/codegen/models/lro_operation.py +6 -18
  18. package/autorest/codegen/models/lro_paging_operation.py +1 -3
  19. package/autorest/codegen/models/model_type.py +21 -73
  20. package/autorest/codegen/models/operation.py +41 -139
  21. package/autorest/codegen/models/operation_group.py +21 -60
  22. package/autorest/codegen/models/paging_operation.py +13 -43
  23. package/autorest/codegen/models/parameter.py +16 -54
  24. package/autorest/codegen/models/parameter_list.py +27 -103
  25. package/autorest/codegen/models/primitive_types.py +15 -49
  26. package/autorest/codegen/models/property.py +8 -28
  27. package/autorest/codegen/models/request_builder.py +11 -39
  28. package/autorest/codegen/models/request_builder_parameter.py +4 -13
  29. package/autorest/codegen/models/response.py +16 -57
  30. package/autorest/codegen/serializers/__init__.py +46 -150
  31. package/autorest/codegen/serializers/builder_serializer.py +113 -402
  32. package/autorest/codegen/serializers/client_serializer.py +25 -78
  33. package/autorest/codegen/serializers/enum_serializer.py +1 -3
  34. package/autorest/codegen/serializers/general_serializer.py +6 -22
  35. package/autorest/codegen/serializers/import_serializer.py +13 -40
  36. package/autorest/codegen/serializers/metadata_serializer.py +7 -21
  37. package/autorest/codegen/serializers/model_init_serializer.py +1 -5
  38. package/autorest/codegen/serializers/model_serializer.py +13 -51
  39. package/autorest/codegen/serializers/operation_groups_serializer.py +1 -3
  40. package/autorest/codegen/serializers/operations_init_serializer.py +2 -8
  41. package/autorest/codegen/serializers/parameter_serializer.py +8 -26
  42. package/autorest/codegen/serializers/request_builders_serializer.py +1 -3
  43. package/autorest/codegen/serializers/sample_serializer.py +13 -39
  44. package/autorest/codegen/serializers/test_serializer.py +10 -30
  45. package/autorest/codegen/serializers/types_serializer.py +1 -3
  46. package/autorest/jsonrpc/__init__.py +1 -3
  47. package/autorest/jsonrpc/server.py +3 -9
  48. package/autorest/jsonrpc/stdstream.py +4 -12
  49. package/autorest/m2r/__init__.py +2 -6
  50. package/autorest/m4reformatter/__init__.py +72 -237
  51. package/autorest/multiapi/__init__.py +4 -11
  52. package/autorest/multiapi/models/client.py +7 -21
  53. package/autorest/multiapi/models/code_model.py +9 -28
  54. package/autorest/multiapi/models/config.py +1 -3
  55. package/autorest/multiapi/models/global_parameters.py +6 -16
  56. package/autorest/multiapi/models/imports.py +5 -9
  57. package/autorest/multiapi/models/operation_mixin_group.py +5 -17
  58. package/autorest/multiapi/serializers/__init__.py +10 -31
  59. package/autorest/multiapi/serializers/import_serializer.py +8 -24
  60. package/autorest/multiapi/utils.py +2 -6
  61. package/autorest/multiclient/__init__.py +1 -3
  62. package/autorest/postprocess/__init__.py +9 -29
  63. package/autorest/postprocess/get_all.py +1 -3
  64. package/autorest/postprocess/venvtools.py +1 -3
  65. package/autorest/preprocess/__init__.py +40 -126
  66. package/install.py +2 -0
  67. package/package.json +1 -1
  68. package/prepare.py +3 -1
  69. package/requirements.txt +1 -1
  70. package/run_cadl.py +1 -3
  71. package/setup.py +25 -25
  72. package/start.py +2 -0
  73. package/venvtools.py +15 -10
@@ -30,18 +30,14 @@ def update_overload_section(
30
30
  if overload_s.get("type"):
31
31
  overload_s["type"] = original_s["type"]
32
32
  if overload_s.get("headers"):
33
- for overload_h, original_h in zip(
34
- overload_s["headers"], original_s["headers"]
35
- ):
33
+ for overload_h, original_h in zip(overload_s["headers"], original_s["headers"]):
36
34
  if overload_h.get("type"):
37
35
  overload_h["type"] = original_h["type"]
38
36
  except KeyError as exc:
39
37
  raise ValueError(overload["name"]) from exc
40
38
 
41
39
 
42
- def add_overload(
43
- yaml_data: Dict[str, Any], body_type: Dict[str, Any], for_flatten_params=False
44
- ):
40
+ def add_overload(yaml_data: Dict[str, Any], body_type: Dict[str, Any], for_flatten_params=False):
45
41
  overload = copy.deepcopy(yaml_data)
46
42
  overload["isOverload"] = True
47
43
  overload["bodyParameter"]["type"] = body_type
@@ -53,9 +49,7 @@ def add_overload(
53
49
  if for_flatten_params:
54
50
  overload["bodyParameter"]["flattened"] = True
55
51
  else:
56
- overload["parameters"] = [
57
- p for p in overload["parameters"] if not p.get("inFlattenedBody")
58
- ]
52
+ overload["parameters"] = [p for p in overload["parameters"] if not p.get("inFlattenedBody")]
59
53
  # for yaml sync, we need to make sure all of the responses, parameters, and exceptions' types have the same yaml id
60
54
  for overload_p, original_p in zip(overload["parameters"], yaml_data["parameters"]):
61
55
  overload_p["type"] = original_p["type"]
@@ -63,9 +57,7 @@ def add_overload(
63
57
  update_overload_section(overload, yaml_data, "exceptions")
64
58
 
65
59
  # update content type to be an overloads content type
66
- content_type_param = next(
67
- p for p in overload["parameters"] if p["wireName"].lower() == "content-type"
68
- )
60
+ content_type_param = next(p for p in overload["parameters"] if p["wireName"].lower() == "content-type")
69
61
  content_type_param["inOverload"] = True
70
62
  content_type_param["inDocstring"] = True
71
63
  body_type_description = get_body_type_for_description(overload["bodyParameter"])
@@ -88,25 +80,16 @@ def add_overloads_for_body_param(yaml_data: Dict[str, Any]) -> None:
88
80
  body_parameter = yaml_data["bodyParameter"]
89
81
  if not (
90
82
  body_parameter["type"]["type"] == "combined"
91
- and len(yaml_data["bodyParameter"]["type"]["types"])
92
- > len(yaml_data["overloads"])
83
+ and len(yaml_data["bodyParameter"]["type"]["types"]) > len(yaml_data["overloads"])
93
84
  ):
94
85
  return
95
86
  for body_type in body_parameter["type"]["types"]:
96
- if any(
97
- o
98
- for o in yaml_data["overloads"]
99
- if id(o["bodyParameter"]["type"]) == id(body_type)
100
- ):
87
+ if any(o for o in yaml_data["overloads"] if id(o["bodyParameter"]["type"]) == id(body_type)):
101
88
  continue
102
89
  yaml_data["overloads"].append(add_overload(yaml_data, body_type))
103
90
  if body_type.get("type") == "model" and body_type.get("base") == "json":
104
- yaml_data["overloads"].append(
105
- add_overload(yaml_data, body_type, for_flatten_params=True)
106
- )
107
- content_type_param = next(
108
- p for p in yaml_data["parameters"] if p["wireName"].lower() == "content-type"
109
- )
91
+ yaml_data["overloads"].append(add_overload(yaml_data, body_type, for_flatten_params=True))
92
+ content_type_param = next(p for p in yaml_data["parameters"] if p["wireName"].lower() == "content-type")
110
93
  content_type_param["inOverload"] = False
111
94
  content_type_param["inOverriden"] = True
112
95
  content_type_param["inDocstring"] = True
@@ -116,9 +99,7 @@ def add_overloads_for_body_param(yaml_data: Dict[str, Any]) -> None:
116
99
  content_type_param["optional"] = True
117
100
 
118
101
 
119
- def update_description(
120
- description: Optional[str], default_description: str = ""
121
- ) -> str:
102
+ def update_description(description: Optional[str], default_description: str = "") -> str:
122
103
  if not description:
123
104
  description = default_description
124
105
  description.rstrip(" ")
@@ -179,9 +160,7 @@ def has_json_content_type(yaml_data: Dict[str, Any]) -> bool:
179
160
 
180
161
 
181
162
  def has_multi_part_content_type(yaml_data: Dict[str, Any]) -> bool:
182
- return any(
183
- ct for ct in yaml_data.get("contentTypes", []) if ct == "multipart/form-data"
184
- )
163
+ return any(ct for ct in yaml_data.get("contentTypes", []) if ct == "multipart/form-data")
185
164
 
186
165
 
187
166
  class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
@@ -213,8 +192,7 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
213
192
  body_parameter
214
193
  and body_parameter["type"]["type"] in ("model", "dict", "list")
215
194
  and (
216
- has_json_content_type(body_parameter)
217
- or (self.is_cadl and has_multi_part_content_type(body_parameter))
195
+ has_json_content_type(body_parameter) or (self.is_cadl and has_multi_part_content_type(body_parameter))
218
196
  )
219
197
  and not body_parameter["type"].get("xmlMetadata")
220
198
  and not any(t for t in ["flattened", "groupedBy"] if body_parameter.get(t))
@@ -240,10 +218,7 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
240
218
  return name
241
219
 
242
220
  if self.is_cadl:
243
- reserved_words = {
244
- k: (v + CADL_RESERVED_WORDS.get(k, []))
245
- for k, v in RESERVED_WORDS.items()
246
- }
221
+ reserved_words = {k: (v + CADL_RESERVED_WORDS.get(k, [])) for k, v in RESERVED_WORDS.items()}
247
222
  else:
248
223
  reserved_words = RESERVED_WORDS
249
224
  name = pad_special_chars(name)
@@ -256,26 +231,18 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
256
231
  def update_types(self, yaml_data: List[Dict[str, Any]]) -> None:
257
232
  for type in yaml_data:
258
233
  for property in type.get("properties", []):
259
- property["description"] = update_description(
260
- property.get("description", "")
261
- )
262
- property["clientName"] = self.pad_reserved_words(
263
- property["clientName"].lower(), PadType.PROPERTY
264
- )
234
+ property["description"] = update_description(property.get("description", ""))
235
+ property["clientName"] = self.pad_reserved_words(property["clientName"].lower(), PadType.PROPERTY)
265
236
  add_redefined_builtin_info(property["clientName"], property)
266
237
  if type.get("name"):
267
238
  name = self.pad_reserved_words(type["name"], PadType.MODEL)
268
239
  type["name"] = name[0].upper() + name[1:]
269
- type["description"] = update_description(
270
- type.get("description", ""), type["name"]
271
- )
240
+ type["description"] = update_description(type.get("description", ""), type["name"])
272
241
  type["snakeCaseName"] = to_snake_case(type["name"])
273
242
  if type.get("values"):
274
243
  # we're enums
275
244
  for value in type["values"]:
276
- padded_name = self.pad_reserved_words(
277
- value["name"].lower(), PadType.ENUM
278
- ).upper()
245
+ padded_name = self.pad_reserved_words(value["name"].lower(), PadType.ENUM).upper()
279
246
  if padded_name[0] in "0123456789":
280
247
  padded_name = "ENUM_" + padded_name
281
248
  value["name"] = padded_name
@@ -286,24 +253,16 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
286
253
  yaml_data.append(v["type"])
287
254
 
288
255
  def update_client(self, yaml_data: Dict[str, Any]) -> None:
289
- yaml_data["description"] = update_description(
290
- yaml_data["description"], default_description=yaml_data["name"]
291
- )
256
+ yaml_data["description"] = update_description(yaml_data["description"], default_description=yaml_data["name"])
292
257
  yaml_data["legacyFilename"] = to_snake_case(yaml_data["name"].replace(" ", "_"))
293
258
  parameters = yaml_data["parameters"]
294
259
  for parameter in parameters:
295
260
  self.update_parameter(parameter)
296
261
  if parameter["clientName"] == "credential":
297
262
  policy = parameter["type"].get("policy")
298
- if (
299
- policy
300
- and policy["type"] == "BearerTokenCredentialPolicy"
301
- and self.azure_arm
302
- ):
263
+ if policy and policy["type"] == "BearerTokenCredentialPolicy" and self.azure_arm:
303
264
  policy["type"] = "ARMChallengeAuthenticationPolicy"
304
- policy["credentialScopes"] = [
305
- "https://management.azure.com/.default"
306
- ]
265
+ policy["credentialScopes"] = ["https://management.azure.com/.default"]
307
266
  if (
308
267
  (not self.version_tolerant or self.azure_arm)
309
268
  and parameters
@@ -321,10 +280,7 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
321
280
  property_if_none_match = None
322
281
  for p in o["parameters"]:
323
282
  wire_name_lower = get_wire_name_lower(p)
324
- if (
325
- p["location"] == "header"
326
- and wire_name_lower == "client-request-id"
327
- ):
283
+ if p["location"] == "header" and wire_name_lower == "client-request-id":
328
284
  yaml_data["requestIdHeaderName"] = wire_name_lower
329
285
  if self.version_tolerant and p["location"] == "header":
330
286
  if wire_name_lower == "if-match":
@@ -346,16 +302,13 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
346
302
  o["parameters"] = [
347
303
  item
348
304
  for item in o["parameters"]
349
- if get_wire_name_lower(item)
350
- not in ("if-match", "if-none-match")
305
+ if get_wire_name_lower(item) not in ("if-match", "if-none-match")
351
306
  ] + [property_if_match, property_if_none_match]
352
307
 
353
308
  o["hasEtag"] = True
354
309
  yaml_data["hasEtag"] = True
355
310
 
356
- def get_operation_updater(
357
- self, yaml_data: Dict[str, Any]
358
- ) -> Callable[[Dict[str, Any], Dict[str, Any]], None]:
311
+ def get_operation_updater(self, yaml_data: Dict[str, Any]) -> Callable[[Dict[str, Any], Dict[str, Any]], None]:
359
312
  if yaml_data["discriminator"] == "lropaging":
360
313
  return self.update_lro_paging_operation
361
314
  if yaml_data["discriminator"] == "lro":
@@ -366,13 +319,8 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
366
319
 
367
320
  def update_parameter(self, yaml_data: Dict[str, Any]) -> None:
368
321
  yaml_data["description"] = update_description(yaml_data.get("description", ""))
369
- if not (
370
- yaml_data["location"] == "header"
371
- and yaml_data["clientName"] in ("content_type", "accept")
372
- ):
373
- yaml_data["clientName"] = self.pad_reserved_words(
374
- yaml_data["clientName"].lower(), PadType.PARAMETER
375
- )
322
+ if not (yaml_data["location"] == "header" and yaml_data["clientName"] in ("content_type", "accept")):
323
+ yaml_data["clientName"] = self.pad_reserved_words(yaml_data["clientName"].lower(), PadType.PARAMETER)
376
324
  if yaml_data.get("propertyToParameterName"):
377
325
  # need to create a new one with padded keys and values
378
326
  yaml_data["propertyToParameterName"] = {
@@ -383,20 +331,12 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
383
331
  }
384
332
  wire_name_lower = (yaml_data.get("wireName") or "").lower()
385
333
  if yaml_data["location"] == "header" and (
386
- wire_name_lower in HEADERS_HIDE_IN_METHOD
387
- or yaml_data.get("clientDefaultValue") == "multipart/form-data"
334
+ wire_name_lower in HEADERS_HIDE_IN_METHOD or yaml_data.get("clientDefaultValue") == "multipart/form-data"
388
335
  ):
389
336
  yaml_data["hideInMethod"] = True
390
- if (
391
- self.version_tolerant
392
- and yaml_data["location"] == "header"
393
- and wire_name_lower in HEADERS_CONVERT_IN_METHOD
394
- ):
337
+ if self.version_tolerant and yaml_data["location"] == "header" and wire_name_lower in HEADERS_CONVERT_IN_METHOD:
395
338
  headers_convert(yaml_data, HEADERS_CONVERT_IN_METHOD[wire_name_lower])
396
- if (
397
- wire_name_lower in ["$host", "content-type", "accept"]
398
- and yaml_data["type"]["type"] == "constant"
399
- ):
339
+ if wire_name_lower in ["$host", "content-type", "accept"] and yaml_data["type"]["type"] == "constant":
400
340
  yaml_data["clientDefaultValue"] = yaml_data["type"]["value"]
401
341
 
402
342
  def update_operation(
@@ -406,15 +346,11 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
406
346
  *,
407
347
  is_overload: bool = False,
408
348
  ) -> None:
409
- yaml_data["groupName"] = self.pad_reserved_words(
410
- yaml_data["groupName"], PadType.OPERATION_GROUP
411
- )
349
+ yaml_data["groupName"] = self.pad_reserved_words(yaml_data["groupName"], PadType.OPERATION_GROUP)
412
350
  yaml_data["groupName"] = to_snake_case(yaml_data["groupName"])
413
351
  yaml_data["name"] = yaml_data["name"].lower()
414
352
  yaml_data["name"] = self.pad_reserved_words(yaml_data["name"], PadType.METHOD)
415
- yaml_data["description"] = update_description(
416
- yaml_data["description"], yaml_data["name"]
417
- )
353
+ yaml_data["description"] = update_description(yaml_data["description"], yaml_data["name"])
418
354
  yaml_data["summary"] = update_description(yaml_data.get("summary", ""))
419
355
  body_parameter = yaml_data.get("bodyParameter")
420
356
  for parameter in yaml_data["parameters"]:
@@ -435,12 +371,8 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
435
371
  def _update_lro_operation_helper(self, yaml_data: Dict[str, Any]) -> None:
436
372
  for response in yaml_data.get("responses", []):
437
373
  response["discriminator"] = "lro"
438
- response["pollerSync"] = (
439
- response.get("pollerSync") or "azure.core.polling.LROPoller"
440
- )
441
- response["pollerAsync"] = (
442
- response.get("pollerAsync") or "azure.core.polling.AsyncLROPoller"
443
- )
374
+ response["pollerSync"] = response.get("pollerSync") or "azure.core.polling.LROPoller"
375
+ response["pollerAsync"] = response.get("pollerAsync") or "azure.core.polling.AsyncLROPoller"
444
376
  if not response.get("pollingMethodSync"):
445
377
  response["pollingMethodSync"] = (
446
378
  "azure.mgmt.core.polling.arm_polling.ARMPolling"
@@ -462,9 +394,7 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
462
394
  item_type: Optional[Dict[str, Any]] = None,
463
395
  ) -> None:
464
396
  self.update_lro_operation(code_model, yaml_data, is_overload=is_overload)
465
- self.update_paging_operation(
466
- code_model, yaml_data, is_overload=is_overload, item_type=item_type
467
- )
397
+ self.update_paging_operation(code_model, yaml_data, is_overload=is_overload, item_type=item_type)
468
398
  yaml_data["discriminator"] = "lropaging"
469
399
  for response in yaml_data.get("responses", []):
470
400
  response["discriminator"] = "lropaging"
@@ -483,15 +413,11 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
483
413
  is_overload: bool = False,
484
414
  ) -> None:
485
415
  self.update_operation(code_model, yaml_data, is_overload=is_overload)
486
- self.update_operation(
487
- code_model, yaml_data["initialOperation"], is_overload=is_overload
488
- )
416
+ self.update_operation(code_model, yaml_data["initialOperation"], is_overload=is_overload)
489
417
  self._update_lro_operation_helper(yaml_data)
490
418
  for overload in yaml_data.get("overloads", []):
491
419
  self._update_lro_operation_helper(overload)
492
- self.update_operation(
493
- code_model, overload["initialOperation"], is_overload=True
494
- )
420
+ self.update_operation(code_model, overload["initialOperation"], is_overload=True)
495
421
 
496
422
  def update_paging_operation(
497
423
  self,
@@ -506,9 +432,7 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
506
432
  yaml_data["nextOperation"]["groupName"] = self.pad_reserved_words(
507
433
  yaml_data["nextOperation"]["groupName"], PadType.OPERATION_GROUP
508
434
  )
509
- yaml_data["nextOperation"]["groupName"] = to_snake_case(
510
- yaml_data["nextOperation"]["groupName"]
511
- )
435
+ yaml_data["nextOperation"]["groupName"] = to_snake_case(yaml_data["nextOperation"]["groupName"])
512
436
  for response in yaml_data["nextOperation"].get("responses", []):
513
437
  update_paging_response(response)
514
438
  response["itemType"] = item_type
@@ -516,28 +440,20 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
516
440
  update_paging_response(response)
517
441
  response["itemType"] = item_type
518
442
  for overload in yaml_data.get("overloads", []):
519
- self.update_paging_operation(
520
- code_model, overload, is_overload=True, item_type=item_type
521
- )
443
+ self.update_paging_operation(code_model, overload, is_overload=True, item_type=item_type)
522
444
 
523
- def update_operation_groups(
524
- self, code_model: Dict[str, Any], client: Dict[str, Any]
525
- ) -> None:
445
+ def update_operation_groups(self, code_model: Dict[str, Any], client: Dict[str, Any]) -> None:
526
446
  operation_groups_yaml_data = client["operationGroups"]
527
447
  for operation_group in operation_groups_yaml_data:
528
448
  operation_group["identifyName"] = self.pad_reserved_words(
529
449
  operation_group.get("name", operation_group["propertyName"]),
530
450
  PadType.OPERATION_GROUP,
531
451
  )
532
- operation_group["identifyName"] = to_snake_case(
533
- operation_group["identifyName"]
534
- )
452
+ operation_group["identifyName"] = to_snake_case(operation_group["identifyName"])
535
453
  operation_group["propertyName"] = self.pad_reserved_words(
536
454
  operation_group["propertyName"], PadType.OPERATION_GROUP
537
455
  )
538
- operation_group["propertyName"] = to_snake_case(
539
- operation_group["propertyName"]
540
- )
456
+ operation_group["propertyName"] = to_snake_case(operation_group["propertyName"])
541
457
  operation_group["className"] = update_operation_group_class_name(
542
458
  client["name"], operation_group["className"]
543
459
  )
@@ -574,6 +490,4 @@ class PreProcessPluginAutorest(YamlUpdatePluginAutorest, PreProcessPlugin):
574
490
  if __name__ == "__main__":
575
491
  # CADL pipeline will call this
576
492
  args, unknown_args = parse_args()
577
- PreProcessPlugin(
578
- output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args
579
- ).process()
493
+ PreProcessPlugin(output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args).process()
package/install.py CHANGED
@@ -6,6 +6,7 @@
6
6
  # license information.
7
7
  # --------------------------------------------------------------------------
8
8
  import sys
9
+
9
10
  if not sys.version_info >= (3, 8, 0):
10
11
  raise Exception("Autorest for Python extension requires Python 3.8 at least")
11
12
 
@@ -45,5 +46,6 @@ def main():
45
46
  python_run(venv_context, "pip", ["install", "-r", "requirements.txt"])
46
47
  python_run(venv_context, "pip", ["install", "-e", str(_ROOT_DIR)])
47
48
 
49
+
48
50
  if __name__ == "__main__":
49
51
  main()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.13.16",
3
+ "version": "6.13.17",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "main": "index.js",
6
6
  "repository": {
package/prepare.py CHANGED
@@ -6,6 +6,7 @@
6
6
  # license information.
7
7
  # --------------------------------------------------------------------------
8
8
  import sys
9
+
9
10
  if not sys.version_info >= (3, 8, 0):
10
11
  raise Exception("Autorest for Python extension requires Python 3.8 at least")
11
12
 
@@ -25,9 +26,10 @@ def main():
25
26
 
26
27
  env_builder = venv.EnvBuilder(with_pip=True)
27
28
  venv_context = env_builder.ensure_directories(venv_path)
28
- requirements_path = _ROOT_DIR / 'dev_requirements.txt'
29
+ requirements_path = _ROOT_DIR / "dev_requirements.txt"
29
30
 
30
31
  python_run(venv_context, "pip", ["install", "-r", str(requirements_path)])
31
32
 
33
+
32
34
  if __name__ == "__main__":
33
35
  main()
package/requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  black==24.4.0
2
2
  click==8.1.3
3
3
  docutils==0.19
4
- Jinja2==3.1.3
4
+ Jinja2==3.1.4
5
5
  json-rpc==1.14.0
6
6
  m2r2==0.3.3
7
7
  MarkupSafe==2.1.2
package/run_cadl.py CHANGED
@@ -26,9 +26,7 @@ if __name__ == "__main__":
26
26
  try:
27
27
  import debugpy # pylint: disable=import-outside-toplevel
28
28
  except ImportError:
29
- raise SystemExit(
30
- "Please pip install ptvsd in order to use VSCode debugging"
31
- )
29
+ raise SystemExit("Please pip install ptvsd in order to use VSCode debugging")
32
30
 
33
31
  # 5678 is the default attach port in the VS Code debug configurations
34
32
  debugpy.listen(("localhost", 5678))
package/setup.py CHANGED
@@ -13,42 +13,42 @@ import re
13
13
  from setuptools import setup, find_packages
14
14
 
15
15
 
16
-
17
16
  # Version extraction inspired from 'requests'
18
- with open(os.path.join('autorest', '_version.py'), 'r') as fd:
19
- version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]',
20
- fd.read(), re.MULTILINE).group(1)
17
+ with open(os.path.join("autorest", "_version.py"), "r") as fd:
18
+ version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1)
21
19
 
22
20
  if not version:
23
- raise RuntimeError('Cannot find version information')
21
+ raise RuntimeError("Cannot find version information")
24
22
 
25
23
  setup(
26
24
  name="autorest",
27
25
  version=version,
28
- description='Microsoft Autorest Plugins for Python',
29
- long_description=open('README.md', 'r').read(),
30
- long_description_content_type='text/markdown',
31
- license='MIT License',
32
- author='Microsoft Corporation',
33
- author_email='azpysdkhelp@microsoft.com',
34
- url='https://github.com/Azure/autorest.python',
26
+ description="Microsoft Autorest Plugins for Python",
27
+ long_description=open("README.md", "r").read(),
28
+ long_description_content_type="text/markdown",
29
+ license="MIT License",
30
+ author="Microsoft Corporation",
31
+ author_email="azpysdkhelp@microsoft.com",
32
+ url="https://github.com/Azure/autorest.python",
35
33
  classifiers=[
36
- 'Development Status :: 4 - Beta',
37
- 'Programming Language :: Python',
38
- 'Programming Language :: Python :: 3',
39
- 'Programming Language :: Python :: 3.8',
40
- 'Programming Language :: Python :: 3.9',
41
- 'Programming Language :: Python :: 3.10',
42
- 'Programming Language :: Python :: 3.11',
43
- 'Programming Language :: Python :: 3.12',
44
- 'License :: OSI Approved :: MIT License',
34
+ "Development Status :: 4 - Beta",
35
+ "Programming Language :: Python",
36
+ "Programming Language :: Python :: 3",
37
+ "Programming Language :: Python :: 3.8",
38
+ "Programming Language :: Python :: 3.9",
39
+ "Programming Language :: Python :: 3.10",
40
+ "Programming Language :: Python :: 3.11",
41
+ "Programming Language :: Python :: 3.12",
42
+ "License :: OSI Approved :: MIT License",
45
43
  ],
46
- packages=find_packages(exclude=[
47
- 'test',
48
- ]),
44
+ packages=find_packages(
45
+ exclude=[
46
+ "test",
47
+ ]
48
+ ),
49
49
  install_requires=[
50
50
  "json-rpc",
51
- "Jinja2 >= 2.11", # I need "include" and auto-context + blank line are not indented by default
51
+ "Jinja2 >= 2.11", # I need "include" and auto-context + blank line are not indented by default
52
52
  "pyyaml",
53
53
  "m2r2",
54
54
  "black",
package/start.py CHANGED
@@ -6,6 +6,7 @@
6
6
  # license information.
7
7
  # --------------------------------------------------------------------------
8
8
  import sys
9
+
9
10
  if not sys.version_info >= (3, 8, 0):
10
11
  raise Exception("Autorest for Python extension requires Python 3.8 at least")
11
12
 
@@ -30,5 +31,6 @@ def main():
30
31
  venv_context = env_builder.ensure_directories(venv_path)
31
32
  python_run(venv_context, "autorest.jsonrpc.server", command=sys.argv[1:])
32
33
 
34
+
33
35
  if __name__ == "__main__":
34
36
  main()
package/venvtools.py CHANGED
@@ -31,15 +31,22 @@ class ExtendedEnvBuilder(venv.EnvBuilder):
31
31
  return self.context
32
32
 
33
33
 
34
- def create(env_dir, system_site_packages=False, clear=False,
35
- symlinks=False, with_pip=False, prompt=None, upgrade_deps=False):
34
+ def create(
35
+ env_dir, system_site_packages=False, clear=False, symlinks=False, with_pip=False, prompt=None, upgrade_deps=False
36
+ ):
36
37
  """Create a virtual environment in a directory."""
37
- builder = ExtendedEnvBuilder(system_site_packages=system_site_packages,
38
- clear=clear, symlinks=symlinks, with_pip=with_pip,
39
- prompt=prompt, upgrade_deps=upgrade_deps)
38
+ builder = ExtendedEnvBuilder(
39
+ system_site_packages=system_site_packages,
40
+ clear=clear,
41
+ symlinks=symlinks,
42
+ with_pip=with_pip,
43
+ prompt=prompt,
44
+ upgrade_deps=upgrade_deps,
45
+ )
40
46
  builder.create(env_dir)
41
47
  return builder.context
42
48
 
49
+
43
50
  @contextmanager
44
51
  def create_venv_with_package(packages):
45
52
  """Create a venv with these packages in a temp dir and yielf the env.
@@ -54,17 +61,15 @@ def create_venv_with_package(packages):
54
61
  "pip",
55
62
  "install",
56
63
  ]
57
- subprocess.check_call(pip_call + ['-U', 'pip'])
64
+ subprocess.check_call(pip_call + ["-U", "pip"])
58
65
  if packages:
59
66
  subprocess.check_call(pip_call + packages)
60
67
  yield myenv
61
68
 
69
+
62
70
  def python_run(venv_context, module, command=None, *, additional_dir="."):
63
71
  try:
64
- cmd_line= [
65
- venv_context.env_exe,
66
- "-m", module
67
- ] + (command if command else [])
72
+ cmd_line = [venv_context.env_exe, "-m", module] + (command if command else [])
68
73
  print("Executing: {}".format(" ".join(cmd_line)))
69
74
  subprocess.run(
70
75
  cmd_line,