@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.
- package/autorest/codegen/models/constant_type.py +4 -2
- package/autorest/codegen/models/enum_type.py +3 -1
- package/autorest/codegen/models/imports.py +0 -17
- package/autorest/codegen/templates/enum.py.jinja2 +1 -1
- package/autorest/codegen/templates/model_base.py.jinja2 +1 -8
- package/autorest/codegen/templates/packaging_templates/setup.py.jinja2 +0 -3
- package/package.json +1 -1
|
@@ -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.
|
|
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.
|
|
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
|
|
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
|