@autorest/python 6.12.1 → 6.12.2

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[
@@ -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__ == 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.2",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "main": "index.js",
6
6
  "repository": {