@autorest/python 6.38.1 → 6.39.0
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/README.md +2 -27
- package/autorest/codegen.py +0 -1
- package/autorest/jsonrpc/server.py +0 -3
- package/generator/build/lib/pygen/__init__.py +14 -23
- package/generator/build/lib/pygen/codegen/__init__.py +4 -4
- package/generator/build/lib/pygen/codegen/models/__init__.py +2 -2
- package/generator/build/lib/pygen/codegen/models/base.py +9 -12
- package/generator/build/lib/pygen/codegen/models/base_builder.py +4 -6
- package/generator/build/lib/pygen/codegen/models/client.py +61 -102
- package/generator/build/lib/pygen/codegen/models/code_model.py +29 -29
- package/generator/build/lib/pygen/codegen/models/combined_type.py +7 -7
- package/generator/build/lib/pygen/codegen/models/constant_type.py +4 -11
- package/generator/build/lib/pygen/codegen/models/credential_types.py +9 -11
- package/generator/build/lib/pygen/codegen/models/dictionary_type.py +7 -8
- package/generator/build/lib/pygen/codegen/models/enum_type.py +7 -7
- package/generator/build/lib/pygen/codegen/models/imports.py +24 -29
- package/generator/build/lib/pygen/codegen/models/list_type.py +15 -14
- package/generator/build/lib/pygen/codegen/models/lro_operation.py +6 -6
- package/generator/build/lib/pygen/codegen/models/lro_paging_operation.py +2 -2
- package/generator/build/lib/pygen/codegen/models/model_type.py +11 -11
- package/generator/build/lib/pygen/codegen/models/operation.py +26 -56
- package/generator/build/lib/pygen/codegen/models/operation_group.py +11 -22
- package/generator/build/lib/pygen/codegen/models/paging_operation.py +15 -19
- package/generator/build/lib/pygen/codegen/models/parameter.py +12 -21
- package/generator/build/lib/pygen/codegen/models/parameter_list.py +37 -39
- package/generator/build/lib/pygen/codegen/models/primitive_types.py +24 -18
- package/generator/build/lib/pygen/codegen/models/property.py +10 -10
- package/generator/build/lib/pygen/codegen/models/request_builder.py +7 -8
- package/generator/build/lib/pygen/codegen/models/request_builder_parameter.py +3 -3
- package/generator/build/lib/pygen/codegen/models/response.py +15 -40
- package/generator/build/lib/pygen/codegen/models/utils.py +2 -2
- package/generator/build/lib/pygen/codegen/serializers/__init__.py +26 -42
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +103 -100
- package/generator/build/lib/pygen/codegen/serializers/client_serializer.py +22 -25
- package/generator/build/lib/pygen/codegen/serializers/enum_serializer.py +2 -2
- package/generator/build/lib/pygen/codegen/serializers/general_serializer.py +49 -61
- package/generator/build/lib/pygen/codegen/serializers/import_serializer.py +6 -7
- package/generator/build/lib/pygen/codegen/serializers/model_init_serializer.py +1 -2
- package/generator/build/lib/pygen/codegen/serializers/model_serializer.py +15 -17
- package/generator/build/lib/pygen/codegen/serializers/operation_groups_serializer.py +3 -3
- package/generator/build/lib/pygen/codegen/serializers/operations_init_serializer.py +5 -6
- package/generator/build/lib/pygen/codegen/serializers/parameter_serializer.py +28 -18
- package/generator/build/lib/pygen/codegen/serializers/patch_serializer.py +1 -2
- package/generator/build/lib/pygen/codegen/serializers/request_builders_serializer.py +1 -2
- package/generator/build/lib/pygen/codegen/serializers/sample_serializer.py +9 -14
- package/generator/build/lib/pygen/codegen/serializers/test_serializer.py +7 -7
- package/generator/build/lib/pygen/codegen/serializers/utils.py +2 -2
- package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +30 -24
- package/generator/build/lib/pygen/codegen/templates/model_dpg.py.jinja2 +1 -1
- package/generator/build/lib/pygen/codegen/templates/operation_group.py.jinja2 +1 -11
- package/generator/build/lib/pygen/codegen/templates/operations_folder_init.py.jinja2 +1 -1
- package/generator/build/lib/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +2 -1
- package/generator/build/lib/pygen/codegen/templates/packaging_templates/dev_requirements.txt.jinja2 +1 -1
- package/generator/build/lib/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2 +13 -2
- package/generator/build/lib/pygen/codegen/templates/patch.py.jinja2 +1 -1
- package/generator/build/lib/pygen/codegen/templates/serialization.py.jinja2 +11 -13
- package/generator/build/lib/pygen/codegen/templates/utils.py.jinja2 +6 -6
- package/generator/build/lib/pygen/preprocess/__init__.py +47 -30
- package/generator/build/lib/pygen/preprocess/helpers.py +2 -2
- package/generator/build/lib/pygen/utils.py +6 -6
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/__init__.py +14 -23
- package/generator/pygen/codegen/__init__.py +4 -4
- package/generator/pygen/codegen/models/__init__.py +2 -2
- package/generator/pygen/codegen/models/base.py +9 -12
- package/generator/pygen/codegen/models/base_builder.py +4 -6
- package/generator/pygen/codegen/models/client.py +61 -102
- package/generator/pygen/codegen/models/code_model.py +29 -29
- package/generator/pygen/codegen/models/combined_type.py +7 -7
- package/generator/pygen/codegen/models/constant_type.py +4 -11
- package/generator/pygen/codegen/models/credential_types.py +9 -11
- package/generator/pygen/codegen/models/dictionary_type.py +7 -8
- package/generator/pygen/codegen/models/enum_type.py +7 -7
- package/generator/pygen/codegen/models/imports.py +24 -29
- package/generator/pygen/codegen/models/list_type.py +15 -14
- package/generator/pygen/codegen/models/lro_operation.py +6 -6
- package/generator/pygen/codegen/models/lro_paging_operation.py +2 -2
- package/generator/pygen/codegen/models/model_type.py +11 -11
- package/generator/pygen/codegen/models/operation.py +26 -56
- package/generator/pygen/codegen/models/operation_group.py +11 -22
- package/generator/pygen/codegen/models/paging_operation.py +15 -19
- package/generator/pygen/codegen/models/parameter.py +12 -21
- package/generator/pygen/codegen/models/parameter_list.py +37 -39
- package/generator/pygen/codegen/models/primitive_types.py +24 -18
- package/generator/pygen/codegen/models/property.py +10 -10
- package/generator/pygen/codegen/models/request_builder.py +7 -8
- package/generator/pygen/codegen/models/request_builder_parameter.py +3 -3
- package/generator/pygen/codegen/models/response.py +15 -40
- package/generator/pygen/codegen/models/utils.py +2 -2
- package/generator/pygen/codegen/serializers/__init__.py +26 -42
- package/generator/pygen/codegen/serializers/builder_serializer.py +103 -100
- package/generator/pygen/codegen/serializers/client_serializer.py +22 -25
- package/generator/pygen/codegen/serializers/enum_serializer.py +2 -2
- package/generator/pygen/codegen/serializers/general_serializer.py +49 -61
- package/generator/pygen/codegen/serializers/import_serializer.py +6 -7
- package/generator/pygen/codegen/serializers/model_init_serializer.py +1 -2
- package/generator/pygen/codegen/serializers/model_serializer.py +15 -17
- package/generator/pygen/codegen/serializers/operation_groups_serializer.py +3 -3
- package/generator/pygen/codegen/serializers/operations_init_serializer.py +5 -6
- package/generator/pygen/codegen/serializers/parameter_serializer.py +28 -18
- package/generator/pygen/codegen/serializers/patch_serializer.py +1 -2
- package/generator/pygen/codegen/serializers/request_builders_serializer.py +1 -2
- package/generator/pygen/codegen/serializers/sample_serializer.py +9 -14
- package/generator/pygen/codegen/serializers/test_serializer.py +7 -7
- package/generator/pygen/codegen/serializers/utils.py +2 -2
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +30 -24
- package/generator/pygen/codegen/templates/model_dpg.py.jinja2 +1 -1
- package/generator/pygen/codegen/templates/operation_group.py.jinja2 +1 -11
- package/generator/pygen/codegen/templates/operations_folder_init.py.jinja2 +1 -1
- package/generator/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +2 -1
- package/generator/pygen/codegen/templates/packaging_templates/dev_requirements.txt.jinja2 +1 -1
- package/generator/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2 +13 -2
- package/generator/pygen/codegen/templates/patch.py.jinja2 +1 -1
- package/generator/pygen/codegen/templates/serialization.py.jinja2 +11 -13
- package/generator/pygen/codegen/templates/utils.py.jinja2 +6 -6
- package/generator/pygen/preprocess/__init__.py +47 -30
- package/generator/pygen/preprocess/helpers.py +2 -2
- package/generator/pygen/utils.py +6 -6
- package/generator/pygen.egg-info/SOURCES.txt +0 -2
- package/package.json +2 -2
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
- package/autorest/multiapi/__init__.py +0 -185
- package/autorest/multiapi/models/__init__.py +0 -16
- package/autorest/multiapi/models/client.py +0 -68
- package/autorest/multiapi/models/code_model.py +0 -142
- package/autorest/multiapi/models/config.py +0 -24
- package/autorest/multiapi/models/constant_global_parameter.py +0 -11
- package/autorest/multiapi/models/global_parameter.py +0 -34
- package/autorest/multiapi/models/global_parameters.py +0 -53
- package/autorest/multiapi/models/imports.py +0 -181
- package/autorest/multiapi/models/mixin_operation.py +0 -38
- package/autorest/multiapi/models/operation_group.py +0 -29
- package/autorest/multiapi/models/operation_mixin_group.py +0 -89
- package/autorest/multiapi/serializers/__init__.py +0 -145
- package/autorest/multiapi/serializers/import_serializer.py +0 -181
- package/autorest/multiapi/templates/multiapi_config.py.jinja2 +0 -89
- package/autorest/multiapi/templates/multiapi_init.py.jinja2 +0 -22
- package/autorest/multiapi/templates/multiapi_models.py.jinja2 +0 -9
- package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +0 -39
- package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +0 -163
- package/autorest/multiapi/templates/multiapi_version.py.jinja2 +0 -8
- package/autorest/multiapi/utils.py +0 -51
- package/generator/build/lib/pygen/codegen/serializers/metadata_serializer.py +0 -216
- package/generator/build/lib/pygen/codegen/templates/metadata.json.jinja2 +0 -167
- package/generator/pygen/codegen/serializers/metadata_serializer.py +0 -216
- package/generator/pygen/codegen/templates/metadata.json.jinja2 +0 -167
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import Any, Union, Literal, Optional, cast
|
|
8
8
|
|
|
9
9
|
from .base import BaseType
|
|
10
10
|
from .enum_type import EnumType
|
|
@@ -22,7 +22,7 @@ def _is_legacy(options) -> bool:
|
|
|
22
22
|
return not (options.get("version-tolerant") or options.get("low-level-client"))
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def get_all_operation_groups_recursively(clients:
|
|
25
|
+
def get_all_operation_groups_recursively(clients: list[Client]) -> list[OperationGroup]:
|
|
26
26
|
operation_groups = []
|
|
27
27
|
queue = []
|
|
28
28
|
for client in clients:
|
|
@@ -37,10 +37,10 @@ def get_all_operation_groups_recursively(clients: List[Client]) -> List[Operatio
|
|
|
37
37
|
class ClientNamespaceType:
|
|
38
38
|
def __init__(
|
|
39
39
|
self,
|
|
40
|
-
clients: Optional[
|
|
41
|
-
models: Optional[
|
|
42
|
-
enums: Optional[
|
|
43
|
-
operation_groups: Optional[
|
|
40
|
+
clients: Optional[list[Client]] = None,
|
|
41
|
+
models: Optional[list[ModelType]] = None,
|
|
42
|
+
enums: Optional[list[EnumType]] = None,
|
|
43
|
+
operation_groups: Optional[list[OperationGroup]] = None,
|
|
44
44
|
):
|
|
45
45
|
self.clients = clients or []
|
|
46
46
|
self.models = models or []
|
|
@@ -73,34 +73,34 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
73
73
|
|
|
74
74
|
def __init__(
|
|
75
75
|
self,
|
|
76
|
-
yaml_data:
|
|
76
|
+
yaml_data: dict[str, Any],
|
|
77
77
|
options: OptionsDict,
|
|
78
78
|
) -> None:
|
|
79
79
|
self.yaml_data = yaml_data
|
|
80
80
|
self.options = options
|
|
81
81
|
self.namespace = self.yaml_data["namespace"]
|
|
82
|
-
self.types_map:
|
|
83
|
-
self._model_types:
|
|
82
|
+
self.types_map: dict[int, BaseType] = {} # map yaml id to schema
|
|
83
|
+
self._model_types: list[ModelType] = []
|
|
84
84
|
from . import build_type
|
|
85
85
|
|
|
86
86
|
for type_yaml in yaml_data.get("types", []):
|
|
87
87
|
build_type(yaml_data=type_yaml, code_model=self)
|
|
88
|
-
self.clients:
|
|
88
|
+
self.clients: list[Client] = [
|
|
89
89
|
Client.from_yaml(client_yaml_data, self) for client_yaml_data in yaml_data["clients"]
|
|
90
90
|
]
|
|
91
91
|
if self.options["models-mode"] and self.model_types:
|
|
92
92
|
self.sort_model_types()
|
|
93
|
-
self.named_unions:
|
|
93
|
+
self.named_unions: list[CombinedType] = [
|
|
94
94
|
t for t in self.types_map.values() if isinstance(t, CombinedType) and t.name
|
|
95
95
|
]
|
|
96
96
|
self.cross_language_package_id = self.yaml_data.get("crossLanguagePackageId")
|
|
97
97
|
self.for_test: bool = False
|
|
98
98
|
# key is typespec namespace, value is models/clients/opeartion_groups/enums cache in the namespace
|
|
99
|
-
self._client_namespace_types:
|
|
99
|
+
self._client_namespace_types: dict[str, ClientNamespaceType] = {}
|
|
100
100
|
self.has_subnamespace = False
|
|
101
|
-
self._operations_folder_name:
|
|
102
|
-
self._relative_import_path:
|
|
103
|
-
self.metadata:
|
|
101
|
+
self._operations_folder_name: dict[str, str] = {}
|
|
102
|
+
self._relative_import_path: dict[str, str] = {}
|
|
103
|
+
self.metadata: dict[str, Any] = yaml_data.get("metadata", {})
|
|
104
104
|
|
|
105
105
|
@staticmethod
|
|
106
106
|
def get_imported_namespace_for_client(imported_namespace: str, async_mode: bool = False) -> str:
|
|
@@ -160,7 +160,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
160
160
|
return "_".join(parts) + (str(dot_num) if dot_num > 0 else "")
|
|
161
161
|
|
|
162
162
|
@property
|
|
163
|
-
def client_namespace_types(self) ->
|
|
163
|
+
def client_namespace_types(self) -> dict[str, ClientNamespaceType]:
|
|
164
164
|
if not self._client_namespace_types:
|
|
165
165
|
# calculate client namespace types for each kind of client namespace
|
|
166
166
|
for client in self.clients:
|
|
@@ -202,7 +202,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
202
202
|
return any(client.has_etag for client in self.clients)
|
|
203
203
|
|
|
204
204
|
@staticmethod
|
|
205
|
-
def clients_has_operations(clients:
|
|
205
|
+
def clients_has_operations(clients: list[Client]) -> bool:
|
|
206
206
|
return any(c for c in clients if c.has_operations)
|
|
207
207
|
|
|
208
208
|
@property
|
|
@@ -235,7 +235,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
235
235
|
def client_filename(self) -> str:
|
|
236
236
|
return self.clients[0].filename
|
|
237
237
|
|
|
238
|
-
def get_clients(self, client_namespace: str) ->
|
|
238
|
+
def get_clients(self, client_namespace: str) -> list[Client]:
|
|
239
239
|
"""Get all clients in specific namespace"""
|
|
240
240
|
return self.client_namespace_types.get(client_namespace, ClientNamespaceType()).clients
|
|
241
241
|
|
|
@@ -332,7 +332,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
332
332
|
raise KeyError(f"Couldn't find schema with id {schema_id}") from exc
|
|
333
333
|
|
|
334
334
|
@property
|
|
335
|
-
def model_types(self) ->
|
|
335
|
+
def model_types(self) -> list[ModelType]:
|
|
336
336
|
"""All of the model types in this class"""
|
|
337
337
|
if not self._model_types:
|
|
338
338
|
self._model_types = [
|
|
@@ -341,19 +341,19 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
341
341
|
return self._model_types
|
|
342
342
|
|
|
343
343
|
@model_types.setter
|
|
344
|
-
def model_types(self, val:
|
|
344
|
+
def model_types(self, val: list[ModelType]) -> None:
|
|
345
345
|
self._model_types = val
|
|
346
346
|
|
|
347
347
|
@staticmethod
|
|
348
|
-
def get_public_model_types(models:
|
|
348
|
+
def get_public_model_types(models: list[ModelType]) -> list[ModelType]:
|
|
349
349
|
return [m for m in models if not m.internal and not m.base == "json"]
|
|
350
350
|
|
|
351
351
|
@property
|
|
352
|
-
def public_model_types(self) ->
|
|
352
|
+
def public_model_types(self) -> list[ModelType]:
|
|
353
353
|
return self.get_public_model_types(self.model_types)
|
|
354
354
|
|
|
355
355
|
@property
|
|
356
|
-
def enums(self) ->
|
|
356
|
+
def enums(self) -> list[EnumType]:
|
|
357
357
|
"""All of the enums"""
|
|
358
358
|
return [t for t in self.types_map.values() if isinstance(t, EnumType)]
|
|
359
359
|
|
|
@@ -364,8 +364,8 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
364
364
|
def _sort_model_types_helper(
|
|
365
365
|
self,
|
|
366
366
|
current: ModelType,
|
|
367
|
-
seen_schema_names:
|
|
368
|
-
seen_schema_yaml_ids:
|
|
367
|
+
seen_schema_names: set[str],
|
|
368
|
+
seen_schema_yaml_ids: set[int],
|
|
369
369
|
):
|
|
370
370
|
if current.id in seen_schema_yaml_ids:
|
|
371
371
|
return []
|
|
@@ -389,9 +389,9 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
389
389
|
:return: None
|
|
390
390
|
:rtype: None
|
|
391
391
|
"""
|
|
392
|
-
seen_schema_names:
|
|
393
|
-
seen_schema_yaml_ids:
|
|
394
|
-
sorted_object_schemas:
|
|
392
|
+
seen_schema_names: set[str] = set()
|
|
393
|
+
seen_schema_yaml_ids: set[int] = set()
|
|
394
|
+
sorted_object_schemas: list[ModelType] = []
|
|
395
395
|
for schema in sorted(self.model_types, key=lambda x: x.name.lower()):
|
|
396
396
|
sorted_object_schemas.extend(self._sort_model_types_helper(schema, seen_schema_names, seen_schema_yaml_ids))
|
|
397
397
|
self.model_types = sorted_object_schemas
|
|
@@ -415,7 +415,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
415
415
|
return _is_legacy(self.options)
|
|
416
416
|
|
|
417
417
|
@staticmethod
|
|
418
|
-
def has_non_json_models(models:
|
|
418
|
+
def has_non_json_models(models: list[ModelType]) -> bool:
|
|
419
419
|
return any(m for m in models if m.base != "json")
|
|
420
420
|
|
|
421
421
|
@property
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
-
from typing import Any,
|
|
6
|
+
from typing import Any, Optional, TYPE_CHECKING, Type, Union
|
|
7
7
|
import re
|
|
8
8
|
from .imports import FileImport, ImportType, TypingSection
|
|
9
9
|
from .base import BaseType
|
|
@@ -23,9 +23,9 @@ class CombinedType(BaseType):
|
|
|
23
23
|
|
|
24
24
|
def __init__(
|
|
25
25
|
self,
|
|
26
|
-
yaml_data:
|
|
26
|
+
yaml_data: dict[str, Any],
|
|
27
27
|
code_model: "CodeModel",
|
|
28
|
-
types:
|
|
28
|
+
types: list[BaseType],
|
|
29
29
|
) -> None:
|
|
30
30
|
super().__init__(yaml_data, code_model)
|
|
31
31
|
self.types = types # the types that this type is combining
|
|
@@ -104,7 +104,7 @@ class CombinedType(BaseType):
|
|
|
104
104
|
client_default_value_declaration=client_default_value_declaration,
|
|
105
105
|
)
|
|
106
106
|
|
|
107
|
-
def get_polymorphic_subtypes(self, polymorphic_subtypes:
|
|
107
|
+
def get_polymorphic_subtypes(self, polymorphic_subtypes: list["ModelType"]) -> None:
|
|
108
108
|
raise ValueError("You shouldn't get polymorphic subtypes of multiple types")
|
|
109
109
|
|
|
110
110
|
@property
|
|
@@ -131,7 +131,7 @@ class CombinedType(BaseType):
|
|
|
131
131
|
return file_import
|
|
132
132
|
|
|
133
133
|
@classmethod
|
|
134
|
-
def from_yaml(cls, yaml_data:
|
|
134
|
+
def from_yaml(cls, yaml_data: dict[str, Any], code_model: "CodeModel") -> "BaseType":
|
|
135
135
|
from . import build_type
|
|
136
136
|
|
|
137
137
|
return cls(
|
|
@@ -143,8 +143,8 @@ class CombinedType(BaseType):
|
|
|
143
143
|
def target_model_subtype(
|
|
144
144
|
self,
|
|
145
145
|
target_types: Union[
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
tuple[Type[ModelType]],
|
|
147
|
+
tuple[Type[ModelType], Type[ModelType]],
|
|
148
148
|
],
|
|
149
149
|
) -> Optional[ModelType]:
|
|
150
150
|
for sub_t in self.types:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import logging
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import Any, Optional, TYPE_CHECKING, Union
|
|
8
8
|
from .base import BaseType
|
|
9
9
|
from .imports import FileImport, ImportType, TypingSection
|
|
10
10
|
from .primitive_types import IntegerType, BinaryType, StringType, BooleanType
|
|
@@ -28,7 +28,7 @@ class ConstantType(BaseType):
|
|
|
28
28
|
|
|
29
29
|
def __init__(
|
|
30
30
|
self,
|
|
31
|
-
yaml_data:
|
|
31
|
+
yaml_data: dict[str, Any],
|
|
32
32
|
code_model: "CodeModel",
|
|
33
33
|
value_type: BaseType,
|
|
34
34
|
value: Optional[Union[str, int, float]],
|
|
@@ -82,7 +82,7 @@ class ConstantType(BaseType):
|
|
|
82
82
|
return isinstance(self.value_type, (IntegerType, BinaryType, StringType, BooleanType))
|
|
83
83
|
|
|
84
84
|
@classmethod
|
|
85
|
-
def from_yaml(cls, yaml_data:
|
|
85
|
+
def from_yaml(cls, yaml_data: dict[str, Any], code_model: "CodeModel") -> "ConstantType":
|
|
86
86
|
"""Constructs a ConstantType from yaml data.
|
|
87
87
|
|
|
88
88
|
:param yaml_data: the yaml data from which we will construct this schema
|
|
@@ -109,16 +109,9 @@ class ConstantType(BaseType):
|
|
|
109
109
|
client_default_value_declaration=self.get_declaration(),
|
|
110
110
|
)
|
|
111
111
|
|
|
112
|
-
def
|
|
112
|
+
def imports(self, **kwargs: Any) -> FileImport:
|
|
113
113
|
file_import = super().imports(**kwargs)
|
|
114
114
|
file_import.merge(self.value_type.imports(**kwargs))
|
|
115
|
-
return file_import
|
|
116
|
-
|
|
117
|
-
def imports_for_multiapi(self, **kwargs: Any) -> FileImport:
|
|
118
|
-
return self._imports_shared(**kwargs)
|
|
119
|
-
|
|
120
|
-
def imports(self, **kwargs: Any) -> FileImport:
|
|
121
|
-
file_import = self._imports_shared(**kwargs)
|
|
122
115
|
if self._is_literal:
|
|
123
116
|
file_import.add_submodule_import("typing", "Literal", ImportType.STDLIB, TypingSection.REGULAR)
|
|
124
117
|
return file_import
|
|
@@ -7,9 +7,7 @@ from abc import abstractmethod
|
|
|
7
7
|
from typing import (
|
|
8
8
|
Optional,
|
|
9
9
|
Any,
|
|
10
|
-
Dict,
|
|
11
10
|
TYPE_CHECKING,
|
|
12
|
-
List,
|
|
13
11
|
Generic,
|
|
14
12
|
TypeVar,
|
|
15
13
|
Union,
|
|
@@ -29,7 +27,7 @@ class _CredentialPolicyBaseType:
|
|
|
29
27
|
Inherited by our BearerTokenCredentialPolicy and KeyCredentialPolicy types.
|
|
30
28
|
"""
|
|
31
29
|
|
|
32
|
-
def __init__(self, yaml_data:
|
|
30
|
+
def __init__(self, yaml_data: dict[str, Any], code_model: "CodeModel") -> None:
|
|
33
31
|
self.yaml_data = yaml_data
|
|
34
32
|
self.code_model = code_model
|
|
35
33
|
|
|
@@ -45,10 +43,10 @@ class BearerTokenCredentialPolicyType(_CredentialPolicyBaseType):
|
|
|
45
43
|
|
|
46
44
|
def __init__(
|
|
47
45
|
self,
|
|
48
|
-
yaml_data:
|
|
46
|
+
yaml_data: dict[str, Any],
|
|
49
47
|
code_model: "CodeModel",
|
|
50
|
-
credential_scopes:
|
|
51
|
-
flows: Optional[
|
|
48
|
+
credential_scopes: list[str],
|
|
49
|
+
flows: Optional[dict[str, Any]] = None,
|
|
52
50
|
) -> None:
|
|
53
51
|
super().__init__(yaml_data, code_model)
|
|
54
52
|
self.credential_scopes = credential_scopes
|
|
@@ -60,7 +58,7 @@ class BearerTokenCredentialPolicyType(_CredentialPolicyBaseType):
|
|
|
60
58
|
return f"policies.{policy_name}(self.credential, *self.credential_scopes, {auth_flows}**kwargs)"
|
|
61
59
|
|
|
62
60
|
@classmethod
|
|
63
|
-
def from_yaml(cls, yaml_data:
|
|
61
|
+
def from_yaml(cls, yaml_data: dict[str, Any], code_model: "CodeModel") -> "BearerTokenCredentialPolicyType":
|
|
64
62
|
return cls(yaml_data, code_model, yaml_data["credentialScopes"], yaml_data.get("flows"))
|
|
65
63
|
|
|
66
64
|
|
|
@@ -75,7 +73,7 @@ class ARMChallengeAuthenticationPolicyType(BearerTokenCredentialPolicyType):
|
|
|
75
73
|
class KeyCredentialPolicyType(_CredentialPolicyBaseType):
|
|
76
74
|
def __init__(
|
|
77
75
|
self,
|
|
78
|
-
yaml_data:
|
|
76
|
+
yaml_data: dict[str, Any],
|
|
79
77
|
code_model: "CodeModel",
|
|
80
78
|
key: str,
|
|
81
79
|
scheme: Optional[str] = None,
|
|
@@ -95,7 +93,7 @@ class KeyCredentialPolicyType(_CredentialPolicyBaseType):
|
|
|
95
93
|
return f"policies.{self.credential_name}Policy(self.credential, {params}**kwargs)"
|
|
96
94
|
|
|
97
95
|
@classmethod
|
|
98
|
-
def from_yaml(cls, yaml_data:
|
|
96
|
+
def from_yaml(cls, yaml_data: dict[str, Any], code_model: "CodeModel") -> "KeyCredentialPolicyType":
|
|
99
97
|
return cls(yaml_data, code_model, yaml_data["key"], yaml_data.get("scheme", None))
|
|
100
98
|
|
|
101
99
|
|
|
@@ -114,7 +112,7 @@ class CredentialType(Generic[CredentialPolicyType], BaseType):
|
|
|
114
112
|
|
|
115
113
|
def __init__(
|
|
116
114
|
self,
|
|
117
|
-
yaml_data:
|
|
115
|
+
yaml_data: dict[str, Any],
|
|
118
116
|
code_model: "CodeModel",
|
|
119
117
|
policy: CredentialPolicyType,
|
|
120
118
|
) -> None:
|
|
@@ -138,7 +136,7 @@ class CredentialType(Generic[CredentialPolicyType], BaseType):
|
|
|
138
136
|
return self.docstring_type()
|
|
139
137
|
|
|
140
138
|
@classmethod
|
|
141
|
-
def from_yaml(cls, yaml_data:
|
|
139
|
+
def from_yaml(cls, yaml_data: dict[str, Any], code_model: "CodeModel") -> "CredentialType":
|
|
142
140
|
from . import build_type
|
|
143
141
|
|
|
144
142
|
return cls(
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
-
from typing import Any,
|
|
6
|
+
from typing import Any, Optional, TYPE_CHECKING
|
|
7
7
|
from .base import BaseType
|
|
8
|
-
from .imports import FileImport
|
|
8
|
+
from .imports import FileImport
|
|
9
9
|
|
|
10
10
|
if TYPE_CHECKING:
|
|
11
11
|
from .code_model import CodeModel
|
|
@@ -23,7 +23,7 @@ class DictionaryType(BaseType):
|
|
|
23
23
|
|
|
24
24
|
def __init__(
|
|
25
25
|
self,
|
|
26
|
-
yaml_data:
|
|
26
|
+
yaml_data: dict[str, Any],
|
|
27
27
|
code_model: "CodeModel",
|
|
28
28
|
element_type: BaseType,
|
|
29
29
|
) -> None:
|
|
@@ -48,7 +48,7 @@ class DictionaryType(BaseType):
|
|
|
48
48
|
:return: The type annotation for this schema
|
|
49
49
|
:rtype: str
|
|
50
50
|
"""
|
|
51
|
-
return f"
|
|
51
|
+
return f"dict[str, {self.element_type.type_annotation(**kwargs)}]"
|
|
52
52
|
|
|
53
53
|
def description(self, *, is_operation_file: bool) -> str:
|
|
54
54
|
return "" if is_operation_file else self.yaml_data.get("description", "")
|
|
@@ -79,7 +79,7 @@ class DictionaryType(BaseType):
|
|
|
79
79
|
)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
def get_polymorphic_subtypes(self, polymorphic_subtypes:
|
|
82
|
+
def get_polymorphic_subtypes(self, polymorphic_subtypes: list["ModelType"]) -> None:
|
|
83
83
|
from .model_type import ModelType
|
|
84
84
|
|
|
85
85
|
if isinstance(self.element_type, ModelType):
|
|
@@ -90,7 +90,7 @@ class DictionaryType(BaseType):
|
|
|
90
90
|
polymorphic_subtypes.append(self.element_type)
|
|
91
91
|
|
|
92
92
|
@classmethod
|
|
93
|
-
def from_yaml(cls, yaml_data:
|
|
93
|
+
def from_yaml(cls, yaml_data: dict[str, Any], code_model: "CodeModel") -> "DictionaryType":
|
|
94
94
|
"""Constructs a DictionaryType from yaml data.
|
|
95
95
|
|
|
96
96
|
:param yaml_data: the yaml data from which we will construct this schema
|
|
@@ -99,7 +99,7 @@ class DictionaryType(BaseType):
|
|
|
99
99
|
:return: A created DictionaryType
|
|
100
100
|
:rtype: ~autorest.models.DictionaryType
|
|
101
101
|
"""
|
|
102
|
-
element_schema:
|
|
102
|
+
element_schema: dict[str, Any] = yaml_data["elementType"]
|
|
103
103
|
|
|
104
104
|
from . import build_type # pylint: disable=import-outside-toplevel
|
|
105
105
|
|
|
@@ -113,7 +113,6 @@ class DictionaryType(BaseType):
|
|
|
113
113
|
|
|
114
114
|
def imports(self, **kwargs: Any) -> FileImport:
|
|
115
115
|
file_import = FileImport(self.code_model)
|
|
116
|
-
file_import.add_submodule_import("typing", "Dict", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
117
116
|
file_import.merge(self.element_type.imports(**kwargs))
|
|
118
117
|
return file_import
|
|
119
118
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
-
from typing import Any,
|
|
6
|
+
from typing import Any, TYPE_CHECKING, Optional, cast
|
|
7
7
|
|
|
8
8
|
from .base import BaseType
|
|
9
9
|
from .imports import FileImport, ImportType, TypingSection
|
|
@@ -24,7 +24,7 @@ class EnumValue(BaseType):
|
|
|
24
24
|
|
|
25
25
|
def __init__(
|
|
26
26
|
self,
|
|
27
|
-
yaml_data:
|
|
27
|
+
yaml_data: dict[str, Any],
|
|
28
28
|
code_model: "CodeModel",
|
|
29
29
|
enum_type: "EnumType",
|
|
30
30
|
value_type: BaseType,
|
|
@@ -94,7 +94,7 @@ class EnumValue(BaseType):
|
|
|
94
94
|
return file_import
|
|
95
95
|
|
|
96
96
|
@classmethod
|
|
97
|
-
def from_yaml(cls, yaml_data:
|
|
97
|
+
def from_yaml(cls, yaml_data: dict[str, Any], code_model: "CodeModel") -> "EnumValue":
|
|
98
98
|
"""Constructs an EnumValue from yaml data.
|
|
99
99
|
|
|
100
100
|
:param yaml_data: the yaml data from which we will construct this object
|
|
@@ -127,9 +127,9 @@ class EnumType(BaseType):
|
|
|
127
127
|
|
|
128
128
|
def __init__(
|
|
129
129
|
self,
|
|
130
|
-
yaml_data:
|
|
130
|
+
yaml_data: dict[str, Any],
|
|
131
131
|
code_model: "CodeModel",
|
|
132
|
-
values:
|
|
132
|
+
values: list["EnumValue"],
|
|
133
133
|
value_type: BaseType,
|
|
134
134
|
) -> None:
|
|
135
135
|
super().__init__(yaml_data=yaml_data, code_model=code_model)
|
|
@@ -219,12 +219,12 @@ class EnumType(BaseType):
|
|
|
219
219
|
def instance_check_template(self) -> str:
|
|
220
220
|
return self.value_type.instance_check_template
|
|
221
221
|
|
|
222
|
-
def fill_instance_from_yaml(self, yaml_data:
|
|
222
|
+
def fill_instance_from_yaml(self, yaml_data: dict[str, Any], code_model: "CodeModel") -> None:
|
|
223
223
|
for value in yaml_data["values"]:
|
|
224
224
|
self.values.append(EnumValue.from_yaml(value, code_model))
|
|
225
225
|
|
|
226
226
|
@classmethod
|
|
227
|
-
def from_yaml(cls, yaml_data:
|
|
227
|
+
def from_yaml(cls, yaml_data: dict[str, Any], code_model: "CodeModel") -> "EnumType":
|
|
228
228
|
raise ValueError(
|
|
229
229
|
"You shouldn't call from_yaml for EnumType to avoid recursion. "
|
|
230
230
|
"Please initial a blank EnumType, then call .fill_instance_from_yaml on the created type."
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
from enum import Enum, auto
|
|
7
|
-
from typing import
|
|
8
|
-
from .._utils import get_parent_namespace
|
|
7
|
+
from typing import Optional, Union, TYPE_CHECKING
|
|
9
8
|
|
|
10
9
|
if TYPE_CHECKING:
|
|
11
10
|
from .code_model import CodeModel
|
|
@@ -46,7 +45,7 @@ class ImportModel:
|
|
|
46
45
|
*,
|
|
47
46
|
submodule_name: Optional[str] = None,
|
|
48
47
|
alias: Optional[str] = None,
|
|
49
|
-
version_modules: Optional[
|
|
48
|
+
version_modules: Optional[tuple[tuple[tuple[int, int], str, Optional[str]]]] = None,
|
|
50
49
|
):
|
|
51
50
|
self.typing_section = typing_section
|
|
52
51
|
self.import_type = import_type
|
|
@@ -90,10 +89,10 @@ class TypeDefinition:
|
|
|
90
89
|
|
|
91
90
|
class FileImport:
|
|
92
91
|
def __init__(self, code_model: "CodeModel") -> None:
|
|
93
|
-
self.imports:
|
|
92
|
+
self.imports: list[ImportModel] = []
|
|
94
93
|
self.code_model = code_model
|
|
95
94
|
# has sync and async type definitions
|
|
96
|
-
self.type_definitions:
|
|
95
|
+
self.type_definitions: dict[str, TypeDefinition] = {}
|
|
97
96
|
self.core_library = self.code_model.core_library
|
|
98
97
|
|
|
99
98
|
def _append_import(self, import_model: ImportModel) -> None:
|
|
@@ -114,7 +113,7 @@ class FileImport:
|
|
|
114
113
|
):
|
|
115
114
|
self.imports.append(import_model)
|
|
116
115
|
|
|
117
|
-
def get_imports_from_section(self, typing_section: TypingSection) ->
|
|
116
|
+
def get_imports_from_section(self, typing_section: TypingSection) -> list[ImportModel]:
|
|
118
117
|
return [i for i in self.imports if i.typing_section == typing_section]
|
|
119
118
|
|
|
120
119
|
def add_submodule_import(
|
|
@@ -124,7 +123,7 @@ class FileImport:
|
|
|
124
123
|
import_type: ImportType,
|
|
125
124
|
typing_section: TypingSection = TypingSection.REGULAR,
|
|
126
125
|
alias: Optional[str] = None,
|
|
127
|
-
version_modules: Optional[
|
|
126
|
+
version_modules: Optional[tuple[tuple[tuple[int, int], str, Optional[str]]]] = None,
|
|
128
127
|
) -> None:
|
|
129
128
|
"""Add an import to this import block."""
|
|
130
129
|
self._append_import(
|
|
@@ -167,7 +166,7 @@ class FileImport:
|
|
|
167
166
|
"""Merge the given file import format."""
|
|
168
167
|
for i in file_import.imports:
|
|
169
168
|
self._append_import(i)
|
|
170
|
-
self.type_definitions
|
|
169
|
+
self.type_definitions |= file_import.type_definitions
|
|
171
170
|
|
|
172
171
|
def add_mutable_mapping_import(self) -> None:
|
|
173
172
|
self.add_submodule_import("collections.abc", "MutableMapping", ImportType.STDLIB)
|
|
@@ -180,21 +179,21 @@ class FileImport:
|
|
|
180
179
|
|
|
181
180
|
def to_dict(
|
|
182
181
|
self,
|
|
183
|
-
) ->
|
|
182
|
+
) -> dict[
|
|
184
183
|
TypingSection,
|
|
185
|
-
|
|
184
|
+
dict[
|
|
186
185
|
ImportType,
|
|
187
|
-
|
|
186
|
+
dict[
|
|
188
187
|
str,
|
|
189
|
-
|
|
188
|
+
set[
|
|
190
189
|
Optional[
|
|
191
190
|
Union[
|
|
192
191
|
str,
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
tuple[str, str],
|
|
193
|
+
tuple[
|
|
195
194
|
str,
|
|
196
195
|
Optional[str],
|
|
197
|
-
|
|
196
|
+
tuple[tuple[tuple[int, int], str, Optional[str]]],
|
|
198
197
|
],
|
|
199
198
|
]
|
|
200
199
|
]
|
|
@@ -202,21 +201,21 @@ class FileImport:
|
|
|
202
201
|
],
|
|
203
202
|
],
|
|
204
203
|
]:
|
|
205
|
-
retval:
|
|
204
|
+
retval: dict[
|
|
206
205
|
TypingSection,
|
|
207
|
-
|
|
206
|
+
dict[
|
|
208
207
|
ImportType,
|
|
209
|
-
|
|
208
|
+
dict[
|
|
210
209
|
str,
|
|
211
|
-
|
|
210
|
+
set[
|
|
212
211
|
Optional[
|
|
213
212
|
Union[
|
|
214
213
|
str,
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
tuple[str, str],
|
|
215
|
+
tuple[
|
|
217
216
|
str,
|
|
218
217
|
Optional[str],
|
|
219
|
-
|
|
218
|
+
tuple[tuple[tuple[int, int], str, Optional[str]]],
|
|
220
219
|
],
|
|
221
220
|
]
|
|
222
221
|
]
|
|
@@ -228,11 +227,11 @@ class FileImport:
|
|
|
228
227
|
name_import: Optional[
|
|
229
228
|
Union[
|
|
230
229
|
str,
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
tuple[str, str],
|
|
231
|
+
tuple[
|
|
233
232
|
str,
|
|
234
233
|
Optional[str],
|
|
235
|
-
|
|
234
|
+
tuple[tuple[tuple[int, int], str, Optional[str]]],
|
|
236
235
|
],
|
|
237
236
|
]
|
|
238
237
|
] = None
|
|
@@ -265,10 +264,6 @@ class FileImport:
|
|
|
265
264
|
else:
|
|
266
265
|
# _utils/serialization.py is always in root namespace
|
|
267
266
|
imported_namespace = f"{self.code_model.namespace}._utils"
|
|
268
|
-
if self.code_model.options["multiapi"]:
|
|
269
|
-
# for multiapi, the namespace is azure.mgmt.xxx.v20XX_XX_XX
|
|
270
|
-
# while _utils/serialization.py is in azure.mgmt.xxx
|
|
271
|
-
imported_namespace = f"{get_parent_namespace(imported_namespace)}._utils"
|
|
272
267
|
if msrest_import_type == MsrestImportType.Module:
|
|
273
268
|
self.add_submodule_import(
|
|
274
269
|
self.code_model.get_relative_import_path(serialize_namespace, imported_namespace),
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
-
from typing import Any,
|
|
6
|
+
from typing import Any, Optional, Union, TYPE_CHECKING
|
|
7
7
|
from .base import BaseType
|
|
8
|
-
from .imports import FileImport
|
|
8
|
+
from .imports import FileImport
|
|
9
9
|
|
|
10
10
|
if TYPE_CHECKING:
|
|
11
11
|
from .code_model import CodeModel
|
|
@@ -15,7 +15,7 @@ if TYPE_CHECKING:
|
|
|
15
15
|
class ListType(BaseType):
|
|
16
16
|
def __init__(
|
|
17
17
|
self,
|
|
18
|
-
yaml_data:
|
|
18
|
+
yaml_data: dict[str, Any],
|
|
19
19
|
code_model: "CodeModel",
|
|
20
20
|
element_type: BaseType,
|
|
21
21
|
) -> None:
|
|
@@ -40,7 +40,14 @@ class ListType(BaseType):
|
|
|
40
40
|
):
|
|
41
41
|
# this means we're version tolerant XML, we just return the XML element
|
|
42
42
|
return self.element_type.type_annotation(**kwargs)
|
|
43
|
-
|
|
43
|
+
has_operation_named_list = any(
|
|
44
|
+
o.name.lower() == "list"
|
|
45
|
+
for c in self.code_model.clients
|
|
46
|
+
for og in c.operation_groups
|
|
47
|
+
for o in og.operations
|
|
48
|
+
)
|
|
49
|
+
list_type = "List" if has_operation_named_list and kwargs.get("is_operation_file") else "list"
|
|
50
|
+
return f"{list_type}[{self.element_type.type_annotation(**kwargs)}]"
|
|
44
51
|
|
|
45
52
|
def description(self, *, is_operation_file: bool) -> str:
|
|
46
53
|
return "" if is_operation_file else self.yaml_data.get("description", "")
|
|
@@ -80,8 +87,8 @@ class ListType(BaseType):
|
|
|
80
87
|
return f"list of {self.element_type.docstring_text(**kwargs)}"
|
|
81
88
|
|
|
82
89
|
@property
|
|
83
|
-
def validation(self) -> Optional[
|
|
84
|
-
validation:
|
|
90
|
+
def validation(self) -> Optional[dict[str, Union[bool, int, str]]]:
|
|
91
|
+
validation: dict[str, Union[bool, int, str]] = {}
|
|
85
92
|
if self.max_items:
|
|
86
93
|
validation["max_items"] = self.max_items
|
|
87
94
|
validation["min_items"] = self.min_items or 0
|
|
@@ -102,7 +109,7 @@ class ListType(BaseType):
|
|
|
102
109
|
)
|
|
103
110
|
]
|
|
104
111
|
|
|
105
|
-
def get_polymorphic_subtypes(self, polymorphic_subtypes:
|
|
112
|
+
def get_polymorphic_subtypes(self, polymorphic_subtypes: list["ModelType"]) -> None:
|
|
106
113
|
from .model_type import ModelType
|
|
107
114
|
|
|
108
115
|
if isinstance(self.element_type, ModelType):
|
|
@@ -117,7 +124,7 @@ class ListType(BaseType):
|
|
|
117
124
|
return "isinstance({}, list)"
|
|
118
125
|
|
|
119
126
|
@classmethod
|
|
120
|
-
def from_yaml(cls, yaml_data:
|
|
127
|
+
def from_yaml(cls, yaml_data: dict[str, Any], code_model: "CodeModel") -> "ListType":
|
|
121
128
|
from . import build_type
|
|
122
129
|
|
|
123
130
|
return cls(
|
|
@@ -128,12 +135,6 @@ class ListType(BaseType):
|
|
|
128
135
|
|
|
129
136
|
def imports(self, **kwargs: Any) -> FileImport:
|
|
130
137
|
file_import = FileImport(self.code_model)
|
|
131
|
-
if not (
|
|
132
|
-
self.code_model.options["version-tolerant"]
|
|
133
|
-
and self.element_type.is_xml
|
|
134
|
-
and not self.code_model.options["models-mode"]
|
|
135
|
-
):
|
|
136
|
-
file_import.add_submodule_import("typing", "List", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
137
138
|
file_import.merge(self.element_type.imports(**kwargs))
|
|
138
139
|
return file_import
|
|
139
140
|
|