@autorest/python 6.1.8 → 6.1.10

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.
@@ -75,7 +75,8 @@ class ModelType(
75
75
  @property
76
76
  def serialization_type(self) -> str:
77
77
  if self.code_model.options["models_mode"] == "msrest":
78
- return f"{'' if self.is_public else (self.code_model.models_filename + '.')}{self.name}"
78
+ private_model_path = f"_models.{self.code_model.models_filename}."
79
+ return f"{'' if self.is_public else private_model_path}{self.name}"
79
80
  if self.code_model.options["models_mode"] == "dpg":
80
81
  return f"{'' if self.is_public else '_models.'}_models.{self.name}"
81
82
  return "object"
@@ -1258,9 +1258,12 @@ class _PagingOperationSerializer(
1258
1258
  response = builder.responses[0]
1259
1259
  deserialized = "pipeline_response.http_response.json()"
1260
1260
  if self.code_model.options["models_mode"] == "msrest":
1261
- deserialized = (
1262
- f'self._deserialize("{response.serialization_type}", pipeline_response)'
1263
- )
1261
+ deserialize_type = response.serialization_type
1262
+ pylint_disable = " # pylint: disable=protected-access"
1263
+ if isinstance(response.type, ModelType) and response.type.is_public:
1264
+ deserialize_type = f'"{response.serialization_type}"'
1265
+ pylint_disable = ""
1266
+ deserialized = f"self._deserialize(\n {deserialize_type}, pipeline_response{pylint_disable}\n)"
1264
1267
  elif self.code_model.options["models_mode"] == "dpg":
1265
1268
  deserialized = (
1266
1269
  f"_deserialize({response.serialization_type}, pipeline_response)"
@@ -1440,6 +1443,7 @@ class _LROOperationSerializer(_OperationSerializer[LROOperationType]):
1440
1443
  retval.append(" response_headers = {}")
1441
1444
  if (
1442
1445
  not self.code_model.options["models_mode"]
1446
+ or self.code_model.options["models_mode"] == "dpg"
1443
1447
  or builder.lro_response.headers
1444
1448
  ):
1445
1449
  retval.append(" response = pipeline_response.http_response")
@@ -386,7 +386,7 @@ def update_response(
386
386
  def _get_default_content_type( # pylint: disable=too-many-return-statements
387
387
  content_types: Iterable[str],
388
388
  ) -> Optional[str]:
389
- json_values = [ct for ct in content_types if JSON_REGEXP.match(ct)]
389
+ json_values = [ct for ct in content_types if JSON_REGEXP.match(ct.split(";")[0])]
390
390
  if json_values:
391
391
  if "application/json" in json_values:
392
392
  return "application/json"
@@ -29,10 +29,11 @@ class {{ code_model.client.name }}OperationsMixin(object):
29
29
  mixin_instance = OperationClass()
30
30
  mixin_instance._client = self._client
31
31
  mixin_instance._config = self._config
32
+ mixin_instance._config.api_version = api_version
32
33
  mixin_instance._serialize = Serializer(self._models_dict(api_version))
33
34
  {% if not code_model.client.client_side_validation %}
34
35
  mixin_instance._serialize.client_side_validation = False
35
36
  {% endif %}
36
37
  mixin_instance._deserialize = Deserializer(self._models_dict(api_version))
37
38
  return {{ "await " if mixin_operation.coroutine(async_mode) }}mixin_instance.{{ mixin_operation.name }}({{ mixin_operation.call(async_mode) }})
38
- {% endfor %}
39
+ {% endfor %}
@@ -135,6 +135,7 @@ class {{ code_model.client.name }}({% if code_model.operation_mixin_group.mixin_
135
135
  {% endfor %}
136
136
  else:
137
137
  raise ValueError("API version {} does not have operation group '{{ operation_group.name }}'".format(api_version))
138
+ self._config.api_version = api_version
138
139
  return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
139
140
  {% endfor %}
140
141
 
@@ -131,11 +131,13 @@ class PostProcessPlugin(Plugin): # pylint: disable=abstract-method
131
131
  f for f in folders if f.stem in ["operations", "_operations"]
132
132
  ]
133
133
  for operations_folder in operations_folders:
134
- aio = ".aio" if operations_folder.parent.stem == "aio" else ""
134
+ sub_namespace = ".".join(
135
+ str(operations_folder.relative_to(self.base_folder)).split(os.sep)
136
+ )
135
137
  self.fix_imports_in_init(
136
138
  generated_file_name="_operations",
137
139
  folder_path=operations_folder,
138
- namespace=f"{self.namespace}{aio}.{operations_folder.stem}",
140
+ namespace=f"{self.namespace}.{sub_namespace}",
139
141
  )
140
142
  shutil.rmtree(f"{str(self.output_folder)}/.temp_folder")
141
143
  return True
@@ -155,7 +157,7 @@ class PostProcessPlugin(Plugin): # pylint: disable=abstract-method
155
157
  k: None for k in customized_objects_str.split(",")
156
158
  }.keys() # filter out duplicates
157
159
  file = (folder_path / "__init__.py").relative_to(self.output_folder)
158
- file_content = self.read_file(file)
160
+ file_content = self.read_file(file).replace("\r\n", "\n")
159
161
  added_objs = []
160
162
  for obj in customized_objects:
161
163
  if f" import {obj}\n" in file_content:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.1.8",
3
+ "version": "6.1.10",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "@autorest/system-requirements": "~1.0.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@microsoft.azure/autorest.testserver": "^3.3.38",
24
+ "@microsoft.azure/autorest.testserver": "^3.3.41",
25
25
  "typescript": "^4.8.3"
26
26
  },
27
27
  "files": [