@autorest/python 6.4.5 → 6.4.6

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.
@@ -140,7 +140,11 @@ class _ParameterBase(
140
140
 
141
141
  def type_annotation(self, **kwargs: Any) -> str:
142
142
  kwargs["is_operation_file"] = True
143
- type_annot = self.type.type_annotation(**kwargs)
143
+ # special logic for api-version parameter
144
+ if self.is_api_version:
145
+ type_annot = "str"
146
+ else:
147
+ type_annot = self.type.type_annotation(**kwargs)
144
148
  if self.optional and self.client_default_value is None:
145
149
  return f"Optional[{type_annot}]"
146
150
  return type_annot
@@ -176,9 +180,13 @@ class _ParameterBase(
176
180
 
177
181
  def imports(self, async_mode: bool, **kwargs: Any) -> FileImport:
178
182
  file_import = self._imports_shared(async_mode, **kwargs)
179
- file_import.merge(
180
- self.type.imports(is_operation_file=True, async_mode=async_mode, **kwargs)
181
- )
183
+ # special logic for api-version parameter
184
+ if not self.is_api_version:
185
+ file_import.merge(
186
+ self.type.imports(
187
+ is_operation_file=True, async_mode=async_mode, **kwargs
188
+ )
189
+ )
182
190
  if self.default_to_unset_sentinel:
183
191
  file_import.add_submodule_import("typing", "Any", ImportType.STDLIB)
184
192
  file_import.define_mypy_type(
@@ -127,6 +127,7 @@ class ParameterSerializer:
127
127
  if pop_headers_kwarg != PopKwargType.NO or pop_params_kwarg != PopKwargType.NO:
128
128
  retval.append("")
129
129
  for kwarg in parameters:
130
+ type_annot = kwarg.type_annotation()
130
131
  if kwarg.client_default_value is not None or kwarg.optional:
131
132
  if check_client_input and kwarg.check_client_input:
132
133
  default_value = f"self._config.{kwarg.client_name}"
@@ -145,11 +146,10 @@ class ParameterSerializer:
145
146
  f"_{kwarg_dict}.pop('{kwarg.rest_api_name}', {default_value})"
146
147
  )
147
148
  retval.append(
148
- f"{kwarg.client_name}: {kwarg.type_annotation()} = kwargs.pop('{kwarg.client_name}', "
149
+ f"{kwarg.client_name}: {type_annot} = kwargs.pop('{kwarg.client_name}', "
149
150
  + f"{default_value})"
150
151
  )
151
152
  else:
152
- type_annot = kwarg.type_annotation()
153
153
  retval.append(
154
154
  f"{kwarg.client_name}: {type_annot} = kwargs.pop('{kwarg.client_name}')"
155
155
  )
@@ -1,7 +1,5 @@
1
1
  {% import 'operation_tools.jinja2' as op_tools %}
2
2
  {% import 'keywords.jinja2' as keywords %}
3
- {% set only_path = client.code_model.options["only_path_and_body_params_positional"] %}
4
- {% set method_location = "keywordOnly" if only_path else "positional" %}
5
3
  {
6
4
  "chosen_version": {{ chosen_version | tojson }},
7
5
  "total_api_version_list": {{ total_api_version_list | tojson }},
@@ -52,15 +50,15 @@
52
50
  "description": "API version to use if no profile is provided, or if missing in profile.",
53
51
  "docstring_type": "str",
54
52
  "required": false,
55
- "method_location": {{ method_location | tojson }}
53
+ "method_location": "positional"
56
54
  },
57
55
  {% if not client.has_parameterized_host %}
58
- "{{ "endpoint" if only_path else "base_url" }}": {
56
+ "base_url": {
59
57
  "signature": {{ client.parameters.host.method_signature(async_mode=False) | tojson }},
60
58
  "description": "Service URL",
61
59
  "docstring_type": "str",
62
60
  "required": false,
63
- "method_location": {{ method_location | tojson }}
61
+ "method_location": "positional"
64
62
  },
65
63
  {% endif %}
66
64
  "profile": {
@@ -68,7 +66,7 @@
68
66
  "description": "A profile definition, from KnownProfiles to dict.",
69
67
  "docstring_type": "azure.profiles.KnownProfiles",
70
68
  "required": false,
71
- "method_location": {{ method_location | tojson }}
69
+ "method_location": "positional"
72
70
  }
73
71
  },
74
72
  "async": {
@@ -77,15 +75,15 @@
77
75
  "description": "API version to use if no profile is provided, or if missing in profile.",
78
76
  "docstring_type": "str",
79
77
  "required": false,
80
- "method_location": {{ method_location | tojson }}
78
+ "method_location": "positional"
81
79
  },
82
80
  {% if not client.has_parameterized_host %}
83
- "{{ "endpoint" if only_path else "base_url" }}": {
81
+ "base_url": {
84
82
  "signature": {{ client.parameters.host.method_signature(async_mode=True) | tojson }},
85
83
  "description": "Service URL",
86
84
  "docstring_type": "str",
87
85
  "required": false,
88
- "method_location": {{ method_location | tojson }}
86
+ "method_location": "positional"
89
87
  },
90
88
  {% endif %}
91
89
  "profile": {
@@ -93,7 +91,7 @@
93
91
  "description": "A profile definition, from KnownProfiles to dict.",
94
92
  "docstring_type": "azure.profiles.KnownProfiles",
95
93
  "required": false,
96
- "method_location": {{ method_location | tojson }}
94
+ "method_location": "positional"
97
95
  }
98
96
  }
99
97
  }
@@ -994,11 +994,7 @@ class M4Reformatter(
994
994
  if name == "$host":
995
995
  # I am the non-parameterized endpoint. Modify name based off of flag
996
996
 
997
- client_name = (
998
- "endpoint"
999
- if self.only_path_and_body_parameters_positional
1000
- else "base_url"
1001
- )
997
+ client_name = "endpoint" if self.version_tolerant else "base_url"
1002
998
  global_parameter["language"]["default"]["description"] = "Service URL."
1003
999
  elif (
1004
1000
  global_parameter.get("origin") == "modelerfour:synthesized/api-version"
@@ -1129,7 +1125,7 @@ class M4Reformatter(
1129
1125
  "skipUrlEncoding": True,
1130
1126
  "inOverload": False,
1131
1127
  }
1132
- if self.only_path_and_body_parameters_positional:
1128
+ if self.version_tolerant:
1133
1129
  parameters.append(credential)
1134
1130
  else:
1135
1131
  parameters.insert(0, credential)
@@ -325,14 +325,22 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
325
325
  code_model: Dict[str, Any],
326
326
  yaml_data: Dict[str, Any],
327
327
  is_overload: bool = False,
328
+ item_type: Optional[Dict[str, Any]] = None,
328
329
  ) -> None:
329
330
  self.update_lro_operation(code_model, yaml_data, is_overload=is_overload)
330
- self.update_paging_operation(code_model, yaml_data, is_overload=is_overload)
331
+ self.update_paging_operation(
332
+ code_model, yaml_data, is_overload=is_overload, item_type=item_type
333
+ )
331
334
  yaml_data["discriminator"] = "lropaging"
332
335
  for response in yaml_data.get("responses", []):
333
336
  response["discriminator"] = "lropaging"
334
337
  for overload in yaml_data.get("overloads", []):
335
- self.update_lro_paging_operation(code_model, overload, is_overload=True)
338
+ self.update_lro_paging_operation(
339
+ code_model,
340
+ overload,
341
+ is_overload=True,
342
+ item_type=yaml_data["responses"][0]["itemType"],
343
+ )
336
344
 
337
345
  def update_lro_operation(
338
346
  self,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.4.5",
3
+ "version": "6.4.6",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "main": "index.js",
6
6
  "repository": {
package/requirements.txt CHANGED
@@ -6,7 +6,7 @@ json-rpc==1.14.0
6
6
  m2r2==0.3.3
7
7
  MarkupSafe==2.1.2
8
8
  mistune==0.8.4
9
- pathspec==0.11.0
10
- platformdirs==3.1.0
9
+ pathspec==0.11.1
10
+ platformdirs==3.2.0
11
11
  PyYAML==6.0
12
12
  tomli==2.0.1