@autorest/python 6.12.1 → 6.12.3

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.
@@ -6,7 +6,7 @@
6
6
  import logging
7
7
  from typing import Dict, Any, Optional, TYPE_CHECKING
8
8
  from .base import BaseType
9
- from .imports import FileImport
9
+ from .imports import FileImport, ImportType, TypingSection
10
10
  from .primitive_types import IntegerType, BinaryType, StringType, BooleanType
11
11
  from .utils import add_to_description
12
12
 
@@ -134,7 +134,9 @@ class ConstantType(BaseType):
134
134
  def imports(self, **kwargs: Any) -> FileImport:
135
135
  file_import = self._imports_shared(**kwargs)
136
136
  if self._is_literal:
137
- file_import.add_literal_import()
137
+ file_import.add_submodule_import(
138
+ "typing", "Literal", ImportType.STDLIB, TypingSection.REGULAR
139
+ )
138
140
  return file_import
139
141
 
140
142
  @property
@@ -78,7 +78,9 @@ class EnumValue(BaseType):
78
78
  def imports(self, **kwargs: Any) -> FileImport:
79
79
  file_import = FileImport(self.code_model)
80
80
  file_import.merge(self.value_type.imports(**kwargs))
81
- file_import.add_literal_import()
81
+ file_import.add_submodule_import(
82
+ "typing", "Literal", ImportType.STDLIB, TypingSection.REGULAR
83
+ )
82
84
  file_import.add_submodule_import(
83
85
  "._enums", self.enum_type.name, ImportType.LOCAL, TypingSection.REGULAR
84
86
  )
@@ -204,23 +204,6 @@ class FileImport:
204
204
  )
205
205
  self.add_submodule_import("typing", "Any", ImportType.STDLIB)
206
206
 
207
- def add_literal_import(self) -> None:
208
- self.add_import("sys", ImportType.STDLIB)
209
- self.add_submodule_import(
210
- "typing_extensions",
211
- "Literal",
212
- ImportType.BYVERSION,
213
- TypingSection.REGULAR,
214
- None,
215
- (
216
- (
217
- (3, 8),
218
- "typing",
219
- "pylint: disable=no-name-in-module, ungrouped-imports",
220
- ),
221
- ),
222
- )
223
-
224
207
  def to_dict(
225
208
  self,
226
209
  ) -> Dict[
@@ -700,19 +700,6 @@ class _OperationSerializer(
700
700
  retval.append(_api_version_validation(builder))
701
701
  return retval
702
702
 
703
- def param_description(self, builder: OperationType) -> List[str]:
704
- description_list = super().param_description(builder)
705
- if builder.expose_stream_keyword and builder.has_response_body:
706
- description_list.append(
707
- ":keyword bool stream: Whether to stream the response of this operation. "
708
- "Defaults to False. You will have to context manage the returned stream."
709
- )
710
- if not self.code_model.options["version_tolerant"]:
711
- description_list.append(
712
- ":keyword callable cls: A custom type or function that will be passed the direct response"
713
- )
714
- return description_list
715
-
716
703
  def pop_kwargs_from_signature(self, builder: OperationType) -> List[str]:
717
704
  kwargs_to_pop = builder.parameters.kwargs_to_pop
718
705
  kwargs = self.parameter_serializer.pop_kwargs_from_signature(
@@ -1543,25 +1530,6 @@ class _LROOperationSerializer(_OperationSerializer[LROOperationType]):
1543
1530
  self.async_mode = async_mode
1544
1531
  self.parameter_serializer = ParameterSerializer()
1545
1532
 
1546
- def param_description(self, builder: LROOperationType) -> List[str]:
1547
- retval = super().param_description(builder)
1548
- retval.append(
1549
- ":keyword str continuation_token: A continuation token to restart a poller from a saved state."
1550
- )
1551
- retval.append(
1552
- f":keyword polling: By default, your polling method will be {builder.get_polling_method(self.async_mode)}. "
1553
- "Pass in False for this operation to not poll, or pass in your own initialized polling object for a"
1554
- " personal polling strategy."
1555
- )
1556
- retval.append(
1557
- f":paramtype polling: bool or ~{builder.get_base_polling_method_path(self.async_mode)}"
1558
- )
1559
- retval.append(
1560
- ":keyword int polling_interval: Default waiting time between two polls for LRO operations "
1561
- "if no Retry-After header is present."
1562
- )
1563
- return retval
1564
-
1565
1533
  def serialize_path(self, builder: LROOperationType) -> List[str]:
1566
1534
  return self.parameter_serializer.serialize_path(
1567
1535
  builder.parameters.path, self.serializer_name
@@ -32,8 +32,8 @@ SPECIAL_HEADER_SERIALIZATION: Dict[str, List[str]] = {
32
32
  ],
33
33
  "repeatability-first-sent": [
34
34
  """if "Repeatability-First-Sent" not in _headers:""",
35
- """ _headers["Repeatability-First-Sent"] = _SERIALIZER.serialize_data(datetime.datetime.now(),
36
- "rfc-1123")""",
35
+ """ _headers["Repeatability-First-Sent"] = _SERIALIZER.serialize_data(""",
36
+ """ datetime.datetime.now(datetime.timezone.utc), "rfc-1123")""",
37
37
  ],
38
38
  "client-request-id": [],
39
39
  "x-ms-client-request-id": [],
@@ -8,6 +8,6 @@ class {{ enum.name }}({{ enum.value_type.type_annotation(is_operation_file=False
8
8
  {% for value in enum.values %}
9
9
  {{ value.name }} = {{ enum.value_type.get_declaration(value.value) }}
10
10
  {% if value.description(is_operation_file=False) %}
11
- """{{ value.description(is_operation_file=False) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n #: ') }}"""
11
+ """{{ value.description(is_operation_file=False) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}"""
12
12
  {% endif %}
13
13
  {% endfor %}
@@ -625,14 +625,7 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=R0911, R0915,
625
625
 
626
626
  # is it a literal?
627
627
  try:
628
- if sys.version_info >= (3, 8):
629
- from typing import (
630
- Literal,
631
- ) # pylint: disable=no-name-in-module, ungrouped-imports
632
- else:
633
- from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
634
-
635
- if annotation.__origin__ == Literal:
628
+ if annotation.__origin__ is typing.Literal:
636
629
  return None
637
630
  except AttributeError:
638
631
  pass
@@ -96,9 +96,6 @@ setup(
96
96
  {% else %}
97
97
  "azure-core<2.0.0,>=1.29.5",
98
98
  {% endif %}
99
- {% if code_model.need_typing_extensions %}
100
- "typing-extensions>=4.3.0; python_version<'3.8.0'",
101
- {% endif %}
102
99
  ],
103
100
  {% if package_mode %}
104
101
  python_requires=">=3.8",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.12.1",
3
+ "version": "6.12.3",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "main": "index.js",
6
6
  "repository": {
package/requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  black==22.12.0
2
2
  click==8.1.3
3
3
  docutils==0.19
4
- Jinja2==3.1.2
4
+ Jinja2==3.1.3
5
5
  json-rpc==1.14.0
6
6
  m2r2==0.3.3
7
7
  MarkupSafe==2.1.2