@autorest/python 6.2.6 → 6.2.8

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 (33) hide show
  1. package/autorest/black/__init__.py +3 -2
  2. package/autorest/codegen/__init__.py +1 -1
  3. package/autorest/codegen/models/base.py +9 -1
  4. package/autorest/codegen/models/client.py +4 -2
  5. package/autorest/codegen/models/operation.py +6 -6
  6. package/autorest/codegen/models/operation_group.py +0 -6
  7. package/autorest/codegen/models/primitive_types.py +50 -0
  8. package/autorest/codegen/serializers/__init__.py +17 -8
  9. package/autorest/codegen/serializers/builder_serializer.py +61 -24
  10. package/autorest/codegen/serializers/client_serializer.py +4 -3
  11. package/autorest/codegen/serializers/metadata_serializer.py +7 -1
  12. package/autorest/codegen/serializers/model_serializer.py +8 -12
  13. package/autorest/codegen/serializers/operation_groups_serializer.py +1 -0
  14. package/autorest/codegen/serializers/parameter_serializer.py +3 -3
  15. package/autorest/codegen/serializers/patch_serializer.py +2 -4
  16. package/autorest/codegen/serializers/sample_serializer.py +23 -14
  17. package/autorest/codegen/serializers/utils.py +6 -0
  18. package/autorest/codegen/templates/client.py.jinja2 +3 -12
  19. package/autorest/codegen/templates/config.py.jinja2 +2 -5
  20. package/autorest/codegen/templates/keywords.jinja2 +2 -2
  21. package/autorest/codegen/templates/metadata.json.jinja2 +2 -2
  22. package/autorest/codegen/templates/model_base.py.jinja2 +2 -4
  23. package/autorest/codegen/templates/model_dpg.py.jinja2 +1 -1
  24. package/autorest/codegen/templates/request_builder.py.jinja2 +1 -1
  25. package/autorest/codegen/templates/serialization.py.jinja2 +286 -325
  26. package/autorest/jsonrpc/stdstream.py +1 -1
  27. package/autorest/m2r/__init__.py +2 -2
  28. package/autorest/multiapi/models/imports.py +13 -5
  29. package/autorest/multiapi/serializers/import_serializer.py +1 -1
  30. package/autorest/multiapi/templates/multiapi_config.py.jinja2 +2 -8
  31. package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +1 -1
  32. package/autorest/postprocess/__init__.py +5 -4
  33. package/package.json +1 -1
@@ -28,7 +28,7 @@ def read_message(stream: BinaryIO = sys.stdin.buffer) -> str:
28
28
  try:
29
29
  bytes_size = int(order.split(b":")[1].strip())
30
30
  except Exception as err:
31
- raise ValueError(f"Was unable to read length from {order}") from err # type: ignore
31
+ raise ValueError(f"Was unable to read length from {order!r}") from err
32
32
  # Double new line, so read another emptyline and ignore it
33
33
  stream.readline()
34
34
 
@@ -6,7 +6,7 @@
6
6
  """An autorest MD to RST plugin.
7
7
  """
8
8
  import logging
9
- from typing import Any, Dict, Set
9
+ from typing import Any, Dict, Set, Union
10
10
 
11
11
  import m2r2
12
12
 
@@ -35,7 +35,7 @@ class M2R(YamlUpdatePlugin): # pylint: disable=abstract-method
35
35
  self._convert_docstring_no_cycles(yaml_data, set())
36
36
 
37
37
  def _convert_docstring_no_cycles(
38
- self, yaml_data: Dict[str, Any], node_list: Set[int]
38
+ self, yaml_data: Union[Dict[str, Any], str], node_list: Set[int]
39
39
  ) -> None:
40
40
  """Walk the YAML tree to convert MD to RST."""
41
41
  if id(yaml_data) in node_list:
@@ -42,7 +42,7 @@ class FileImport:
42
42
  ],
43
43
  Tuple[
44
44
  str,
45
- str,
45
+ Optional[str],
46
46
  Tuple[
47
47
  Tuple[Tuple[int, int], str, Optional[str]]
48
48
  ],
@@ -76,7 +76,7 @@ class FileImport:
76
76
  ],
77
77
  Tuple[
78
78
  str,
79
- str,
79
+ Optional[str],
80
80
  Tuple[Tuple[Tuple[int, int], str, Optional[str]]],
81
81
  ],
82
82
  ]
@@ -99,7 +99,11 @@ class FileImport:
99
99
  str,
100
100
  str,
101
101
  ],
102
- Tuple[str, str, Tuple[Tuple[Tuple[int, int], str, Optional[str]]]],
102
+ Tuple[
103
+ str,
104
+ Optional[str],
105
+ Tuple[Tuple[Tuple[int, int], str, Optional[str]]],
106
+ ],
103
107
  ]
104
108
  ] = None,
105
109
  typing_section: TypingSection = TypingSection.REGULAR,
@@ -111,7 +115,11 @@ class FileImport:
111
115
  str,
112
116
  str,
113
117
  ],
114
- Tuple[str, str, Tuple[Tuple[Tuple[int, int], str, Optional[str]]]],
118
+ Tuple[
119
+ str,
120
+ Optional[str],
121
+ Tuple[Tuple[Tuple[int, int], str, Optional[str]]],
122
+ ],
115
123
  ]
116
124
  ] = None
117
125
  name_input = convert_list_to_tuple(name_import)
@@ -148,7 +156,7 @@ class FileImport:
148
156
  ],
149
157
  Tuple[
150
158
  str,
151
- str,
159
+ Optional[str],
152
160
  Tuple[Tuple[Tuple[int, int], str, Optional[str]]],
153
161
  ],
154
162
  ]
@@ -55,7 +55,7 @@ def _serialize_package(
55
55
  ),
56
56
  )
57
57
  )
58
- for submodule_name, alias, version_modules in versioned_modules: # type: ignore
58
+ for submodule_name, alias, version_modules in versioned_modules:
59
59
  for n, (version, module_name, comment) in enumerate(version_modules):
60
60
  buffer.append(
61
61
  "{} sys.version_info >= {}:".format("if" if n == 0 else "elif", version)
@@ -11,7 +11,7 @@ def __init__(
11
11
  {{ parameter.signature(async_mode) }}
12
12
  {% endif %}
13
13
  {% endfor %}
14
- **kwargs # type: Any
14
+ **kwargs: Any
15
15
  ){{" -> None" if async_mode else "" }}:{% endmacro %}
16
16
  {% set version_import = ".._version" if async_mode else "._version" %}
17
17
  {% set async_prefix = "Async" if async_mode else "" %}
@@ -43,9 +43,6 @@ class {{ code_model.client.name }}Configuration(Configuration):
43
43
  """
44
44
 
45
45
  {{ method_signature()|indent }}
46
- {% if not async_mode %}
47
- # type: (...) -> None
48
- {% endif %}
49
46
  {% for parameter in code_model.global_parameters.parameters %}
50
47
  {% if parameter.required %}
51
48
  if {{ parameter.name }} is None:
@@ -70,11 +67,8 @@ class {{ code_model.client.name }}Configuration(Configuration):
70
67
 
71
68
  def _configure(
72
69
  self,
73
- **kwargs{{": Any" if async_mode else " # type: Any"}}
70
+ **kwargs: Any
74
71
  ){{ " -> None" if async_mode else "" }}:
75
- {% if not async_mode %}
76
- # type: (...) -> None
77
- {% endif %}
78
72
  self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
79
73
  self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
80
74
  self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
@@ -14,7 +14,7 @@ def __init__(
14
14
  {% for parameter in code_model.global_parameters.service_client_specific_global_parameters %}
15
15
  {{ parameter.signature(async_mode) }}
16
16
  {% endfor %}
17
- **kwargs # type: Any
17
+ **kwargs: Any
18
18
  ){{" -> None" if async_mode else "" }}:{% endmacro %}
19
19
  {# actual template starts here #}
20
20
  {% set pipeline_client = "ARMPipelineClient" if azure_arm else "PipelineClient" %}
@@ -9,11 +9,12 @@ import os
9
9
  import shutil
10
10
  from venv import EnvBuilder
11
11
  import black
12
+ from black.report import NothingChanged
12
13
  from .venvtools import ExtendedEnvBuilder, python_run
13
14
 
14
15
  from .. import Plugin, PluginAutorest
15
16
 
16
- _BLACK_MODE = black.Mode()
17
+ _BLACK_MODE = black.Mode() # pyright: ignore [reportPrivateImportUsage]
17
18
  _BLACK_MODE.line_length = 120
18
19
 
19
20
 
@@ -24,7 +25,7 @@ def format_file(file: Path, file_content: str) -> str:
24
25
  file_content = black.format_file_contents(
25
26
  file_content, fast=True, mode=_BLACK_MODE
26
27
  )
27
- except black.NothingChanged:
28
+ except NothingChanged:
28
29
  pass
29
30
  return file_content
30
31
 
@@ -170,7 +171,7 @@ class PostProcessPlugin(Plugin): # pylint: disable=abstract-method
170
171
  added_objs.append(obj)
171
172
  file_content = file_content.replace(
172
173
  "try:\n from ._patch import __all__ as _patch_all\n "
173
- "from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import"
174
+ "from ._patch import * # pylint: disable=unused-wildcard-import"
174
175
  "\nexcept ImportError:\n _patch_all = []",
175
176
  "",
176
177
  )
@@ -178,7 +179,7 @@ class PostProcessPlugin(Plugin): # pylint: disable=abstract-method
178
179
  "from ._patch import __all__ as _patch_all", ""
179
180
  )
180
181
  file_content = file_content.replace(
181
- "from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import\n",
182
+ "from ._patch import * # pylint: disable=unused-wildcard-import\n",
182
183
  "",
183
184
  )
184
185
  file_content = file_content.replace(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.2.6",
3
+ "version": "6.2.8",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "repository": {
6
6
  "type": "git",