@autorest/python 6.1.2 → 6.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ChangeLog.md CHANGED
@@ -1,5 +1,61 @@
1
1
  # Release History
2
2
 
3
+ ### 2022-09-06 - 6.1.5
4
+
5
+ | Library | Min Version |
6
+ | ----------------------------------------------------------------------- | ----------- |
7
+ | `@autorest/core` | `3.8.4` |
8
+ | `@autorest/modelerfour` | `4.23.5` |
9
+ | `azure-core` dep of generated code | `1.24.0` |
10
+ | `isodate` dep of generated code | `0.6.1` |
11
+ | `msrest` dep of generated code (If generating legacy code) | `0.7.1` |
12
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.2` |
13
+
14
+ **Bug Fixes**
15
+
16
+ - Fix `api_version` error when there are multi different `api-version`(not multiapi) #1429
17
+ - Fix generator raising `KeyError` in corner case when generating an LRO-paging operation #1425
18
+
19
+ **Other Changes**
20
+
21
+ - Default `304` errors to throw `azure.core.exception.ResourceNotFoundError`s #1415
22
+
23
+ ### 2022-08-31 - 6.1.4
24
+
25
+ | Library | Min Version |
26
+ | ----------------------------------------------------------------------- | ----------- |
27
+ | `@autorest/core` | `3.8.4` |
28
+ | `@autorest/modelerfour` | `4.23.5` |
29
+ | `azure-core` dep of generated code | `1.24.0` |
30
+ | `isodate` dep of generated code | `0.6.1` |
31
+ | `msrest` dep of generated code (If generating legacy code) | `0.7.1` |
32
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.2` |
33
+
34
+ **Bug Fixes**
35
+
36
+ - Fix generation failure for `format: password` #1404
37
+ - Fix `content_type` error when paging with body #1407
38
+ - Fix excessive warning level logging in vendored `failsafe_deserialize` #1419
39
+
40
+ **Other Changes**
41
+
42
+ - Upgrade min dependency for `azure-mgmt-core` to `1.3.2` #1404
43
+
44
+ ### 2022-08-22 - 6.1.3
45
+
46
+ | Library | Min Version |
47
+ | ----------------------------------------------------------------------- | ----------- |
48
+ | `@autorest/core` | `3.8.4` |
49
+ | `@autorest/modelerfour` | `4.23.5` |
50
+ | `azure-core` dep of generated code | `1.24.0` |
51
+ | `isodate` dep of generated code | `0.6.1` |
52
+ | `msrest` dep of generated code (If generating legacy code) | `0.7.1` |
53
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.2` |
54
+
55
+ **Bug Fixes**
56
+
57
+ - Fix circular recursion for lropaging #1400
58
+
3
59
  ### 2022-08-16 - 6.1.2
4
60
 
5
61
  | Library | Min Version |
@@ -53,7 +53,13 @@ def parse_args(need_cadl_file: bool = True):
53
53
  help="Serialized cadl file",
54
54
  required=need_cadl_file,
55
55
  )
56
-
56
+ parser.add_argument(
57
+ "--debug",
58
+ dest="debug",
59
+ help="Debug mode",
60
+ required=False,
61
+ action="store_true",
62
+ )
57
63
  return parser.parse_args()
58
64
 
59
65
 
@@ -122,7 +122,7 @@ class CodeGenerator(Plugin):
122
122
  @staticmethod
123
123
  def _build_package_dependency() -> Dict[str, str]:
124
124
  return {
125
- "dependency_azure_mgmt_core": "azure-mgmt-core<2.0.0,>=1.3.0",
125
+ "dependency_azure_mgmt_core": "azure-mgmt-core<2.0.0,>=1.3.2",
126
126
  "dependency_azure_core": "azure-core<2.0.0,>=1.24.0",
127
127
  "dependency_msrest": "msrest>=0.7.1",
128
128
  }
@@ -140,6 +140,7 @@ TYPE_TO_OBJECT = {
140
140
  "AzureKeyCredentialPolicy": AzureKeyCredentialPolicyType,
141
141
  "any-object": AnyObjectType,
142
142
  "unixtime": UnixTimeType,
143
+ "credential": StringType,
143
144
  }
144
145
  _LOGGER = logging.getLogger(__name__)
145
146
 
@@ -159,18 +159,18 @@ class TokenCredentialType(
159
159
  """Type of a token credential. Used by BearerAuth and ARMChallenge policies"""
160
160
 
161
161
  def type_annotation(self, **kwargs: Any) -> str: # pylint: disable=no-self-use
162
- if kwargs.pop("async_mode"):
162
+ if kwargs.get("async_mode"):
163
163
  return '"AsyncTokenCredential"'
164
164
  return '"TokenCredential"'
165
165
 
166
166
  def docstring_type(self, **kwargs: Any) -> str: # pylint: disable=no-self-use
167
- if kwargs.pop("async_mode"):
167
+ if kwargs.get("async_mode"):
168
168
  return "~azure.core.credentials_async.AsyncTokenCredential"
169
169
  return "~azure.core.credentials.TokenCredential"
170
170
 
171
171
  def imports(self, **kwargs: Any) -> FileImport: # pylint: disable=no-self-use
172
172
  file_import = FileImport()
173
- if kwargs.pop("async_mode"):
173
+ if kwargs.get("async_mode"):
174
174
  file_import.add_submodule_import(
175
175
  "azure.core.credentials_async",
176
176
  "AsyncTokenCredential",
@@ -72,16 +72,20 @@ class ModelType(BaseType): # pylint: disable=too-many-instance-attributes
72
72
  @property
73
73
  def serialization_type(self) -> str:
74
74
  if self.code_model.options["models_mode"]:
75
- return self.name
75
+ return (
76
+ self.name
77
+ if self.is_public
78
+ else f"{self.code_model.models_filename}.{self.name}"
79
+ )
76
80
  return "object"
77
81
 
78
82
  def type_annotation(self, **kwargs: Any) -> str:
79
83
  if self.code_model.options["models_mode"]:
80
84
  is_operation_file = kwargs.pop("is_operation_file", False)
81
- if self.is_public:
82
- retval = f"_models.{self.name}"
83
- return retval if is_operation_file else f'"{retval}"'
84
- return self.name if is_operation_file else f'"{self.name}"'
85
+ retval = f"_models.{self.name}"
86
+ if not self.is_public:
87
+ retval = f"{self.code_model.models_filename}.{retval}"
88
+ return retval if is_operation_file else f'"{retval}"'
85
89
  return "ET.Element" if self.is_xml else "JSON"
86
90
 
87
91
  def docstring_type(self, **kwargs: Any) -> str:
@@ -250,16 +254,9 @@ class ModelType(BaseType): # pylint: disable=too-many-instance-attributes
250
254
  relative_path = kwargs.pop("relative_path", None)
251
255
  if self.code_model.options["models_mode"] and relative_path:
252
256
  # add import for models in operations file
253
- if self.is_public:
254
- file_import.add_submodule_import(
255
- relative_path, "models", ImportType.LOCAL, alias="_models"
256
- )
257
- else:
258
- file_import.add_submodule_import(
259
- f"{relative_path}models.{self.code_model.models_filename}",
260
- self.name,
261
- ImportType.LOCAL,
262
- )
257
+ file_import.add_submodule_import(
258
+ relative_path, "models", ImportType.LOCAL, alias="_models"
259
+ )
263
260
  if self.code_model.options["models_mode"]:
264
261
  return file_import
265
262
  file_import.add_submodule_import(
@@ -291,27 +291,22 @@ class OperationBase( # pylint: disable=too-many-public-methods
291
291
  file_import.merge(self.parameters.body_parameter.type.imports(**kwargs))
292
292
 
293
293
  # Exceptions
294
- file_import.add_submodule_import(
295
- "azure.core.exceptions", "map_error", ImportType.AZURECORE
296
- )
294
+ errors = [
295
+ "map_error",
296
+ "HttpResponseError",
297
+ "ClientAuthenticationError",
298
+ "ResourceNotFoundError",
299
+ "ResourceExistsError",
300
+ "ResourceNotModifiedError",
301
+ ]
302
+ for error in errors:
303
+ file_import.add_submodule_import(
304
+ "azure.core.exceptions", error, ImportType.AZURECORE
305
+ )
297
306
  if self.code_model.options["azure_arm"]:
298
307
  file_import.add_submodule_import(
299
308
  "azure.mgmt.core.exceptions", "ARMErrorFormat", ImportType.AZURECORE
300
309
  )
301
- file_import.add_submodule_import(
302
- "azure.core.exceptions", "HttpResponseError", ImportType.AZURECORE
303
- )
304
- file_import.add_submodule_import(
305
- "azure.core.exceptions",
306
- "ClientAuthenticationError",
307
- ImportType.AZURECORE,
308
- )
309
- file_import.add_submodule_import(
310
- "azure.core.exceptions", "ResourceNotFoundError", ImportType.AZURECORE
311
- )
312
- file_import.add_submodule_import(
313
- "azure.core.exceptions", "ResourceExistsError", ImportType.AZURECORE
314
- )
315
310
 
316
311
  if self.has_kwargs_to_pop_with_default(
317
312
  self.parameters.kwargs_to_pop, ParameterLocation.HEADER
@@ -122,13 +122,13 @@ class BinaryIteratorType(PrimitiveType):
122
122
  return "IO"
123
123
 
124
124
  def docstring_type(self, **kwargs: Any) -> str:
125
- return "AsyncIterator[bytes]" if kwargs.pop("async_mode") else "Iterator[bytes]"
125
+ return "AsyncIterator[bytes]" if kwargs.get("async_mode") else "Iterator[bytes]"
126
126
 
127
127
  def type_annotation(self, **kwargs: Any) -> str:
128
128
  return self.docstring_type(**kwargs)
129
129
 
130
130
  def docstring_text(self, **kwargs: Any) -> str:
131
- iterator = "Async iterator" if kwargs.pop("async_mode") else "Iterator"
131
+ iterator = "Async iterator" if kwargs.get("async_mode") else "Iterator"
132
132
  return f"{iterator} of the response bytes"
133
133
 
134
134
  @property
@@ -137,7 +137,7 @@ class BinaryIteratorType(PrimitiveType):
137
137
 
138
138
  def imports(self, **kwargs: Any) -> FileImport:
139
139
  file_import = FileImport()
140
- iterator = "AsyncIterator" if kwargs.pop("async_mode") else "Iterator"
140
+ iterator = "AsyncIterator" if kwargs.get("async_mode") else "Iterator"
141
141
  file_import.add_submodule_import("typing", iterator, ImportType.STDLIB)
142
142
  return file_import
143
143
 
@@ -170,7 +170,7 @@ class PagingResponse(Response):
170
170
 
171
171
  def _imports_shared(self, **kwargs: Any) -> FileImport:
172
172
  file_import = super()._imports_shared(**kwargs)
173
- async_mode = kwargs.pop("async_mode")
173
+ async_mode = kwargs.get("async_mode", False)
174
174
  pager_import_path = ".".join(self.get_pager_path(async_mode).split(".")[:-1])
175
175
  pager = self.get_pager(async_mode)
176
176
 
@@ -179,7 +179,7 @@ class PagingResponse(Response):
179
179
 
180
180
  def imports(self, **kwargs: Any) -> FileImport:
181
181
  file_import = self._imports_shared(**kwargs)
182
- async_mode = kwargs.pop("async_mode")
182
+ async_mode = kwargs.get("async_mode")
183
183
  if async_mode:
184
184
  file_import.add_submodule_import(
185
185
  "azure.core.async_paging", "AsyncList", ImportType.AZURECORE
@@ -234,16 +234,14 @@ class LROResponse(Response):
234
234
  return self.get_base_polling_method_path(async_mode).split(".")[-1]
235
235
 
236
236
  def type_annotation(self, **kwargs: Any) -> str:
237
- return f"{self.get_poller(kwargs.pop('async_mode'))}[{super().type_annotation(**kwargs)}]"
237
+ return f"{self.get_poller(kwargs.get('async_mode', False))}[{super().type_annotation(**kwargs)}]"
238
238
 
239
239
  def docstring_type(self, **kwargs: Any) -> str:
240
- return f"~{self.get_poller_path(kwargs.pop('async_mode'))}[{super().docstring_type(**kwargs)}]"
240
+ return f"~{self.get_poller_path(kwargs.get('async_mode', False))}[{super().docstring_type(**kwargs)}]"
241
241
 
242
242
  def docstring_text(self, **kwargs) -> str:
243
243
  super_text = super().docstring_text(**kwargs)
244
- base_description = (
245
- f"An instance of {self.get_poller(kwargs.pop('async_mode'))} that returns "
246
- )
244
+ base_description = f"An instance of {self.get_poller(kwargs.get('async_mode', False))} that returns "
247
245
  if not self.code_model.options["version_tolerant"]:
248
246
  base_description += "either "
249
247
  return base_description + super_text
@@ -297,11 +295,11 @@ class LROResponse(Response):
297
295
  class LROPagingResponse(LROResponse, PagingResponse):
298
296
  def type_annotation(self, **kwargs: Any) -> str:
299
297
  paging_type_annotation = PagingResponse.type_annotation(self, **kwargs)
300
- return f"{self.get_poller(kwargs.pop('async_mode'))}[{paging_type_annotation}]"
298
+ return f"{self.get_poller(kwargs.get('async_mode', False))}[{paging_type_annotation}]"
301
299
 
302
300
  def docstring_type(self, **kwargs: Any) -> str:
303
301
  paging_docstring_type = PagingResponse.docstring_type(self, **kwargs)
304
- return f"~{self.get_poller_path(kwargs.pop('async_mode'))}[{paging_docstring_type}]"
302
+ return f"~{self.get_poller_path(kwargs.get('async_mode', False))}[{paging_docstring_type}]"
305
303
 
306
304
  def docstring_text(self, **kwargs) -> str:
307
305
  base_description = (
@@ -708,8 +708,13 @@ class _OperationSerializer(
708
708
  retval.extend(self._serialize_body_parameter(builder))
709
709
  return retval
710
710
 
711
- def _initialize_overloads(self, builder: OperationType) -> List[str]:
711
+ def _initialize_overloads(
712
+ self, builder: OperationType, is_paging: bool = False
713
+ ) -> List[str]:
712
714
  retval: List[str] = []
715
+ # For paging, we put body parameter in local place outside `prepare_request`
716
+ if is_paging:
717
+ return retval
713
718
  same_content_type = (
714
719
  len(
715
720
  set(
@@ -883,6 +888,7 @@ class _OperationSerializer(
883
888
  request_builder: RequestBuilderType,
884
889
  template_url: Optional[str] = None,
885
890
  is_next_request: bool = False,
891
+ is_paging: bool = False,
886
892
  ) -> List[str]:
887
893
  retval = []
888
894
  if builder.parameters.grouped:
@@ -893,7 +899,7 @@ class _OperationSerializer(
893
899
  retval.extend(_serialize_flattened_body(builder.parameters.body_parameter))
894
900
  if builder.overloads:
895
901
  # we are only dealing with two overloads. If there are three, we generate an abstract operation
896
- retval.extend(self._initialize_overloads(builder))
902
+ retval.extend(self._initialize_overloads(builder, is_paging=is_paging))
897
903
  elif builder.parameters.has_body:
898
904
  # non-overloaded body
899
905
  retval.extend(self._create_body_parameter(builder))
@@ -906,8 +912,12 @@ class _OperationSerializer(
906
912
  retval.extend(self._postprocess_http_request(builder, template_url))
907
913
  return retval
908
914
 
909
- def call_request_builder(self, builder: OperationType) -> List[str]:
910
- return self._call_request_builder_helper(builder, builder.request_builder)
915
+ def call_request_builder(
916
+ self, builder: OperationType, is_paging: bool = False
917
+ ) -> List[str]:
918
+ return self._call_request_builder_helper(
919
+ builder, builder.request_builder, is_paging=is_paging
920
+ )
911
921
 
912
922
  def response_headers_and_deserialization(
913
923
  self,
@@ -1033,6 +1043,8 @@ class _OperationSerializer(
1033
1043
  retval.append(" 404: ResourceNotFoundError,")
1034
1044
  if not 409 in builder.non_default_error_status_codes:
1035
1045
  retval.append(" 409: ResourceExistsError,")
1046
+ if not 304 in builder.non_default_error_status_codes:
1047
+ retval.append(" 304: ResourceNotModifiedError,")
1036
1048
  for excep in builder.non_default_errors:
1037
1049
  error_model_str = ""
1038
1050
  if (
@@ -1061,6 +1073,11 @@ class _OperationSerializer(
1061
1073
  " 409: lambda response: ResourceExistsError(response=response"
1062
1074
  f"{error_model_str}{error_format_str}),"
1063
1075
  )
1076
+ elif status_code == 304:
1077
+ retval.append(
1078
+ " 304: lambda response: ResourceNotModifiedError(response=response"
1079
+ f"{error_model_str}{error_format_str}),"
1080
+ )
1064
1081
  elif not error_model_str and not error_format_str:
1065
1082
  retval.append(f" {status_code}: HttpResponseError,")
1066
1083
  else:
@@ -1070,7 +1087,8 @@ class _OperationSerializer(
1070
1087
  )
1071
1088
  else:
1072
1089
  retval.append(
1073
- " 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError"
1090
+ " 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, "
1091
+ "304: ResourceNotModifiedError"
1074
1092
  )
1075
1093
  retval.append("}")
1076
1094
  retval.append("error_map.update(kwargs.pop('error_map', {}) or {})")
@@ -1116,6 +1134,8 @@ class _PagingOperationSerializer(
1116
1134
  def decorators(self, builder: PagingOperationType) -> List[str]:
1117
1135
  """Decorators for the method"""
1118
1136
  retval: List[str] = []
1137
+ if builder.is_overload:
1138
+ return ["@overload"]
1119
1139
  if self.code_model.options["tracing"] and builder.want_tracing:
1120
1140
  retval.append("@distributed_trace")
1121
1141
  return retval
@@ -1168,10 +1188,14 @@ class _PagingOperationSerializer(
1168
1188
  return retval
1169
1189
 
1170
1190
  def _prepare_request_callback(self, builder: PagingOperationType) -> List[str]:
1171
- retval = ["def prepare_request(next_link=None):"]
1191
+ retval = self._initialize_overloads(builder)
1192
+ retval.append("def prepare_request(next_link=None):")
1172
1193
  retval.append(" if not next_link:")
1173
1194
  retval.extend(
1174
- [f" {line}" for line in self.call_request_builder(builder)]
1195
+ [
1196
+ f" {line}"
1197
+ for line in self.call_request_builder(builder, is_paging=True)
1198
+ ]
1175
1199
  )
1176
1200
  retval.append("")
1177
1201
  retval.append(" else:")
@@ -1,5 +1,8 @@
1
1
  {% import 'operation_tools.jinja2' as op_tools with context %}
2
2
  {# actual template starts here #}
3
+ {% if operation.overloads and operation.public %}
4
+ {{ op_tools.generate_overloads(operation_serializer, operation) }}
5
+ {% endif %}
3
6
  {{ operation_serializer.method_signature_and_response_type_annotation(operation) }}
4
7
  {% if operation.public %}
5
8
  {{ op_tools.description(operation, operation_serializer) | indent }}{% endif %}
@@ -18,4 +21,4 @@
18
21
  {% endif %}
19
22
  {% if not code_model.options["version_tolerant"] %}
20
23
  {{ operation_serializer.get_metadata_url(operation) -}}
21
- {% endif %}
24
+ {% endif %}
@@ -1524,7 +1524,7 @@ class Deserializer(object):
1524
1524
  try:
1525
1525
  return self(target_obj, data, content_type=content_type)
1526
1526
  except:
1527
- _LOGGER.warning(
1527
+ _LOGGER.debug(
1528
1528
  "Ran into a deserialization error. Ignoring since this is failsafe deserialization",
1529
1529
  exc_info=True
1530
1530
  )
@@ -2003,4 +2003,4 @@ class Deserializer(object):
2003
2003
  msg = "Cannot deserialize to unix datetime object."
2004
2004
  raise_with_traceback(DeserializationError, msg, err)
2005
2005
  else:
2006
- return date_obj
2006
+ return date_obj
@@ -426,6 +426,10 @@ class M4Reformatter(
426
426
  ): # pylint: disable=too-many-public-methods
427
427
  """Add Python naming information."""
428
428
 
429
+ def __init__(self, *args, **kwargs) -> None:
430
+ super().__init__(*args, **kwargs)
431
+ self.check_client_input: bool = False
432
+
429
433
  @property
430
434
  def azure_arm(self) -> bool:
431
435
  return bool(self._autorestapi.get_boolean_value("azure-arm"))
@@ -802,7 +806,7 @@ class M4Reformatter(
802
806
  param["inDocstring"] = False
803
807
  if self.legacy:
804
808
  param["implementation"] = "Method"
805
- param["checkClientInput"] = True
809
+ param["checkClientInput"] = self.check_client_input
806
810
  if has_flattened_body and param.get("targetProperty"):
807
811
  retval.append(self.update_flattened_parameter(param, body_parameter))
808
812
  continue
@@ -935,6 +939,8 @@ class M4Reformatter(
935
939
 
936
940
  client_name = "base_url" if self.legacy else "endpoint"
937
941
  global_parameter["language"]["default"]["description"] = "Service URL."
942
+ elif name == "api_version":
943
+ self.check_client_input = True
938
944
  global_params.append(
939
945
  self.update_parameter(
940
946
  global_parameter, override_client_name=client_name
@@ -263,28 +263,37 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
263
263
  )
264
264
 
265
265
  def update_lro_paging_operation(
266
- self, code_model: Dict[str, Any], yaml_data: Dict[str, Any]
266
+ self,
267
+ code_model: Dict[str, Any],
268
+ yaml_data: Dict[str, Any],
269
+ is_overload: bool = False,
267
270
  ) -> None:
268
- self.update_lro_operation(code_model, yaml_data)
269
- self.update_paging_operation(code_model, yaml_data)
271
+ self.update_lro_operation(code_model, yaml_data, is_overload=is_overload)
272
+ self.update_paging_operation(code_model, yaml_data, is_overload=is_overload)
270
273
  yaml_data["discriminator"] = "lropaging"
271
274
  for response in yaml_data.get("responses", []):
272
275
  response["discriminator"] = "lropaging"
273
276
  for overload in yaml_data.get("overloads", []):
274
- self.update_lro_paging_operation(code_model, overload)
277
+ self.update_lro_paging_operation(code_model, overload, is_overload=True)
275
278
 
276
279
  def update_lro_operation(
277
- self, code_model: Dict[str, Any], yaml_data: Dict[str, Any]
280
+ self,
281
+ code_model: Dict[str, Any],
282
+ yaml_data: Dict[str, Any],
283
+ is_overload: bool = False,
278
284
  ) -> None:
279
- self.update_operation(code_model, yaml_data)
285
+ self.update_operation(code_model, yaml_data, is_overload=is_overload)
280
286
  self._update_lro_operation_helper(yaml_data)
281
287
  for overload in yaml_data.get("overloads", []):
282
288
  self._update_lro_operation_helper(overload)
283
289
 
284
290
  def update_paging_operation(
285
- self, code_model: Dict[str, Any], yaml_data: Dict[str, Any]
291
+ self,
292
+ code_model: Dict[str, Any],
293
+ yaml_data: Dict[str, Any],
294
+ is_overload: bool = False,
286
295
  ) -> None:
287
- self.update_operation(code_model, yaml_data)
296
+ self.update_operation(code_model, yaml_data, is_overload=is_overload)
288
297
  if not yaml_data.get("pagerSync"):
289
298
  yaml_data["pagerSync"] = "azure.core.paging.ItemPaged"
290
299
  if not yaml_data.get("pagerAsync"):
@@ -319,7 +328,7 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
319
328
  update_paging_response(response)
320
329
  response["itemType"] = item_type
321
330
  for overload in yaml_data.get("overloads", []):
322
- self.update_paging_operation(code_model, overload)
331
+ self.update_paging_operation(code_model, overload, is_overload=True)
323
332
 
324
333
  def update_operation_groups(self, yaml_data: Dict[str, Any]) -> None:
325
334
  operation_groups_yaml_data = yaml_data["operationGroups"]
package/package.json CHANGED
@@ -1,44 +1,45 @@
1
1
  {
2
- "name": "@autorest/python",
3
- "version": "6.1.2",
4
- "description": "The Python extension for generators in AutoRest.",
5
- "scripts": {
6
- "prepare": "node run-python3.js prepare.py",
7
- "start": "node run-python3.js start.py",
8
- "install": "node run-python3.js install.py",
9
- "debug": "node run-python3.js start.py --debug"
10
- },
11
- "repository": {
12
- "type": "git",
13
- "url": "https://github.com/Azure/autorest.python/tree/autorestv3"
14
- },
15
- "readme": "https://github.com/Azure/autorest.python/blob/autorestv3/README.md",
16
- "keywords": [
17
- "autorest",
18
- "python"
19
- ],
20
- "author": "Microsoft Corporation",
21
- "license": "MIT",
22
- "bugs": {
23
- "url": "https://github.com/Azure/autorest.python/issues"
24
- },
25
- "homepage": "https://github.com/Azure/autorest.python/blob/autorestv3/README.md",
26
- "dependencies": {
27
- "@autorest/system-requirements": "~1.0.0"
28
- },
29
- "devDependencies": {
30
- "@microsoft.azure/autorest.testserver": "^3.3.31"
31
- },
32
- "files": [
33
- "autorest/**/*.py",
34
- "autorest/**/*.jinja2",
35
- "setup.py",
36
- "install.py",
37
- "prepare.py",
38
- "start.py",
39
- "venvtools.py",
40
- "run-python3.js",
41
- "requirements.txt",
42
- "run_cadl.py"
43
- ]
2
+ "name": "@autorest/python",
3
+ "version": "6.1.5",
4
+ "description": "The Python extension for generators in AutoRest.",
5
+ "scripts": {
6
+ "prepare": "node run-python3.js prepare.py",
7
+ "start": "node run-python3.js start.py",
8
+ "install": "node run-python3.js install.py",
9
+ "debug": "node run-python3.js start.py --debug"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/Azure/autorest.python/tree/autorestv3"
14
+ },
15
+ "readme": "https://github.com/Azure/autorest.python/blob/autorestv3/README.md",
16
+ "keywords": [
17
+ "autorest",
18
+ "python"
19
+ ],
20
+ "author": "Microsoft Corporation",
21
+ "license": "MIT",
22
+ "bugs": {
23
+ "url": "https://github.com/Azure/autorest.python/issues"
24
+ },
25
+ "homepage": "https://github.com/Azure/autorest.python/blob/autorestv3/README.md",
26
+ "dependencies": {
27
+ "@autorest/system-requirements": "~1.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@microsoft.azure/autorest.testserver": "^3.3.38",
31
+ "typescript": "^4.7.4"
32
+ },
33
+ "files": [
34
+ "autorest/**/*.py",
35
+ "autorest/**/*.jinja2",
36
+ "setup.py",
37
+ "install.py",
38
+ "prepare.py",
39
+ "start.py",
40
+ "venvtools.py",
41
+ "run-python3.js",
42
+ "requirements.txt",
43
+ "run_cadl.py"
44
+ ]
44
45
  }
package/run_cadl.py CHANGED
@@ -5,11 +5,14 @@
5
5
  # --------------------------------------------------------------------------
6
6
  import sys
7
7
  import venv
8
+ import logging
8
9
  from pathlib import Path
9
10
  from venvtools import python_run
10
11
 
11
12
  _ROOT_DIR = Path(__file__).parent
12
13
 
14
+ _LOGGER = logging.getLogger(__name__)
15
+
13
16
  if __name__ == "__main__":
14
17
  venv_path = _ROOT_DIR / "venv"
15
18
  venv_prexists = venv_path.exists()
@@ -19,6 +22,19 @@ if __name__ == "__main__":
19
22
  env_builder = venv.EnvBuilder(with_pip=True)
20
23
  venv_context = env_builder.ensure_directories(venv_path)
21
24
 
25
+ if "--debug" in sys.argv:
26
+ try:
27
+ import debugpy # pylint: disable=import-outside-toplevel
28
+ except ImportError:
29
+ raise SystemExit(
30
+ "Please pip install ptvsd in order to use VSCode debugging"
31
+ )
32
+
33
+ # 5678 is the default attach port in the VS Code debug configurations
34
+ debugpy.listen(("localhost", 5678))
35
+ debugpy.wait_for_client()
36
+ breakpoint() # pylint: disable=undefined-variable
37
+
22
38
  # run m2r
23
39
  python_run(venv_context, "autorest.m2r.__init__", command=sys.argv[1:])
24
40
  python_run(venv_context, "autorest.preprocess.__init__", command=sys.argv[1:])