@autorest/python 6.2.0 → 6.2.1

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 (73) hide show
  1. package/autorest/codegen/__init__.py +9 -74
  2. package/autorest/codegen/models/__init__.py +11 -12
  3. package/autorest/codegen/models/{base_type.py → base.py} +29 -10
  4. package/autorest/codegen/models/base_builder.py +8 -10
  5. package/autorest/codegen/models/client.py +111 -40
  6. package/autorest/codegen/models/code_model.py +131 -90
  7. package/autorest/codegen/models/combined_type.py +7 -7
  8. package/autorest/codegen/models/constant_type.py +44 -10
  9. package/autorest/codegen/models/credential_types.py +17 -19
  10. package/autorest/codegen/models/dictionary_type.py +7 -9
  11. package/autorest/codegen/models/enum_type.py +19 -24
  12. package/autorest/codegen/models/imports.py +82 -33
  13. package/autorest/codegen/models/list_type.py +11 -15
  14. package/autorest/codegen/models/lro_operation.py +6 -10
  15. package/autorest/codegen/models/model_type.py +20 -21
  16. package/autorest/codegen/models/operation.py +49 -42
  17. package/autorest/codegen/models/operation_group.py +11 -11
  18. package/autorest/codegen/models/paging_operation.py +8 -10
  19. package/autorest/codegen/models/parameter.py +44 -31
  20. package/autorest/codegen/models/parameter_list.py +16 -22
  21. package/autorest/codegen/models/primitive_types.py +12 -23
  22. package/autorest/codegen/models/property.py +11 -11
  23. package/autorest/codegen/models/request_builder.py +19 -19
  24. package/autorest/codegen/models/request_builder_parameter.py +14 -16
  25. package/autorest/codegen/models/response.py +24 -28
  26. package/autorest/codegen/serializers/__init__.py +202 -187
  27. package/autorest/codegen/serializers/builder_serializer.py +46 -49
  28. package/autorest/codegen/serializers/client_serializer.py +9 -7
  29. package/autorest/codegen/serializers/enum_serializer.py +4 -4
  30. package/autorest/codegen/serializers/general_serializer.py +26 -36
  31. package/autorest/codegen/serializers/import_serializer.py +30 -36
  32. package/autorest/codegen/serializers/metadata_serializer.py +35 -17
  33. package/autorest/codegen/serializers/model_init_serializer.py +6 -10
  34. package/autorest/codegen/serializers/model_serializer.py +42 -27
  35. package/autorest/codegen/serializers/operation_groups_serializer.py +12 -8
  36. package/autorest/codegen/serializers/operations_init_serializer.py +13 -6
  37. package/autorest/codegen/serializers/patch_serializer.py +4 -4
  38. package/autorest/codegen/serializers/request_builders_serializer.py +6 -6
  39. package/autorest/codegen/serializers/sample_serializer.py +10 -12
  40. package/autorest/codegen/templates/client_container.py.jinja2 +2 -2
  41. package/autorest/codegen/templates/config.py.jinja2 +1 -1
  42. package/autorest/codegen/templates/config_container.py.jinja2 +3 -3
  43. package/autorest/codegen/templates/enum_container.py.jinja2 +2 -2
  44. package/autorest/codegen/templates/init.py.jinja2 +2 -2
  45. package/autorest/codegen/templates/lro_operation.py.jinja2 +1 -1
  46. package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +1 -1
  47. package/autorest/codegen/templates/metadata.json.jinja2 +2 -2
  48. package/autorest/codegen/templates/model_container.py.jinja2 +3 -3
  49. package/autorest/codegen/templates/model_dpg.py.jinja2 +4 -4
  50. package/autorest/codegen/templates/model_init.py.jinja2 +3 -3
  51. package/autorest/codegen/templates/operation.py.jinja2 +1 -1
  52. package/autorest/codegen/templates/operation_group.py.jinja2 +2 -2
  53. package/autorest/codegen/templates/operation_groups_container.py.jinja2 +3 -3
  54. package/autorest/codegen/templates/operation_tools.jinja2 +3 -3
  55. package/autorest/codegen/templates/operations_folder_init.py.jinja2 +4 -4
  56. package/autorest/codegen/templates/packaging_templates/setup.py.jinja2 +4 -1
  57. package/autorest/codegen/templates/paging_operation.py.jinja2 +1 -1
  58. package/autorest/codegen/templates/request_builder.py.jinja2 +1 -1
  59. package/autorest/codegen/templates/request_builders.py.jinja2 +2 -2
  60. package/autorest/codegen/templates/rest_init.py.jinja2 +1 -1
  61. package/autorest/codegen/templates/sample.py.jinja2 +5 -5
  62. package/autorest/codegen/templates/validation.py.jinja2 +1 -1
  63. package/autorest/codegen/templates/vendor.py.jinja2 +6 -6
  64. package/autorest/codegen/templates/version.py.jinja2 +2 -2
  65. package/autorest/m4reformatter/__init__.py +7 -6
  66. package/autorest/multiapi/models/imports.py +89 -18
  67. package/autorest/multiapi/serializers/import_serializer.py +88 -7
  68. package/autorest/multiapi/utils.py +6 -0
  69. package/autorest/preprocess/__init__.py +23 -26
  70. package/package.json +1 -1
  71. package/run_cadl.py +0 -1
  72. package/autorest/cadlflags/__init__.py +0 -130
  73. package/autorest/codegen/models/base_model.py +0 -30
@@ -5,21 +5,20 @@
5
5
  # --------------------------------------------------------------------------
6
6
  from typing import List, Dict, Any, Set, Union
7
7
 
8
- from .base_type import BaseType
8
+ from .base import BaseType
9
9
  from .enum_type import EnumType
10
10
  from .model_type import ModelType
11
11
  from .client import Client
12
12
  from .request_builder import RequestBuilder, OverloadedRequestBuilder
13
- from .operation_group import OperationGroup
13
+ from .constant_type import ConstantType
14
14
 
15
15
 
16
16
  def _is_legacy(options) -> bool:
17
17
  return not (options["version_tolerant"] or options["low_level_client"])
18
18
 
19
19
 
20
- class CodeModel:
21
- """Holds all of the information we have parsed out of the yaml file. The CodeModel is what gets
22
- serialized by the serializers.
20
+ class CodeModel: # pylint: disable=too-many-public-methods
21
+ """Top level code model
23
22
 
24
23
  :param options: Options of the code model. I.e., whether this is for management generation
25
24
  :type options: dict[str, bool]
@@ -37,8 +36,6 @@ class CodeModel:
37
36
  :param primitives: List of schemas we've created that are not EnumSchemas or ObjectSchemas. Maps their
38
37
  yaml id to our created schemas.
39
38
  :type primitives: Dict[int, ~autorest.models.BaseType]
40
- :param operation_groups: The operation groups we are going to serialize
41
- :type operation_groups: list[~autorest.models.OperationGroup]
42
39
  :param package_dependency: All the dependencies needed in setup.py
43
40
  :type package_dependency: Dict[str, str]
44
41
  """
@@ -47,50 +44,60 @@ class CodeModel:
47
44
  self,
48
45
  yaml_data: Dict[str, Any],
49
46
  options: Dict[str, Any],
47
+ *,
48
+ is_subnamespace: bool = False,
50
49
  ) -> None:
51
50
  self.yaml_data = yaml_data
52
51
  self.options = options
53
- self.namespace_models: List["NamespaceModel"] = [
54
- NamespaceModel(namespace_yaml_data, self.options, namespace)
55
- for namespace, namespace_yaml_data in yaml_data.items()
56
- ]
57
-
58
- @property
59
- def is_legacy(self) -> bool:
60
- return _is_legacy(self.options)
61
-
62
- @property
63
- def description(self) -> str:
64
- return self.namespace_models[0].clients[0].description
65
-
66
-
67
- class NamespaceModel:
68
- def __init__(
69
- self, yaml_data: Dict[str, Any], options: Dict[str, Any], namespace: str
70
- ):
71
- self.yaml_data = yaml_data
52
+ self.namespace = self.yaml_data["namespace"]
72
53
  self.types_map: Dict[int, BaseType] = {} # map yaml id to schema
73
54
  self._model_types: List[ModelType] = []
74
- self.options = options
75
55
  from . import build_type
76
56
 
77
57
  for type_yaml in yaml_data.get("types", []):
78
- build_type(yaml_data=type_yaml, namespace_model=self)
79
- self.clients: List[Client] = []
80
- self.namespace = namespace
58
+ build_type(yaml_data=type_yaml, code_model=self)
59
+ self.clients: List[Client] = [
60
+ Client.from_yaml(client_yaml_data, self)
61
+ for client_yaml_data in yaml_data["clients"]
62
+ ]
63
+ self.subnamespace_to_clients: Dict[str, List[Client]] = {
64
+ subnamespace: [
65
+ Client.from_yaml(client_yaml, self, is_subclient=True)
66
+ for client_yaml in client_yamls
67
+ ]
68
+ for subnamespace, client_yamls in yaml_data.get(
69
+ "subnamespaceToClients", {}
70
+ ).items()
71
+ }
72
+ if self.options["models_mode"] and self.model_types:
73
+ self.sort_model_types()
74
+ self.is_subnamespace = is_subnamespace
81
75
 
82
- def lookup_type(self, schema_id: int) -> BaseType:
83
- """Looks to see if the schema has already been created.
76
+ @property
77
+ def has_operations(self) -> bool:
78
+ if any(c for c in self.clients if c.has_operations):
79
+ return True
80
+ return any(
81
+ c
82
+ for clients in self.subnamespace_to_clients.values()
83
+ for c in clients
84
+ if c.has_operations
85
+ )
84
86
 
85
- :param int schema_id: The yaml id of the schema
86
- :return: If created, we return the created schema, otherwise, we throw.
87
- :rtype: ~autorest.models.BaseType
88
- :raises: KeyError if schema is not found
89
- """
90
- try:
91
- return next(type for id, type in self.types_map.items() if id == schema_id)
92
- except StopIteration:
93
- raise KeyError(f"Couldn't find schema with id {schema_id}")
87
+ @property
88
+ def has_non_abstract_operations(self) -> bool:
89
+ for client in self.clients:
90
+ for operation_group in client.operation_groups:
91
+ for operation in operation_group.operations:
92
+ if not operation.abstract:
93
+ return True
94
+ for clients in self.subnamespace_to_clients.values():
95
+ for client in clients:
96
+ for operation_group in client.operation_groups:
97
+ for operation in operation_group.operations:
98
+ if not operation.abstract:
99
+ return True
100
+ return False
94
101
 
95
102
  def lookup_request_builder(
96
103
  self, request_builder_id: int
@@ -104,12 +111,69 @@ class NamespaceModel:
104
111
  raise KeyError(f"No request builder with id {request_builder_id} found.")
105
112
 
106
113
  @property
107
- def operation_groups(self) -> List[OperationGroup]:
108
- return [og for client in self.clients for og in client.operation_groups]
114
+ def rest_layer_name(self) -> str:
115
+ """If we have a separate rest layer, what is its name?"""
116
+ return "rest" if self.options["builders_visibility"] == "public" else "_rest"
109
117
 
110
118
  @property
111
- def request_builders(self) -> List[Union[RequestBuilder, OverloadedRequestBuilder]]:
112
- return [rb for client in self.clients for rb in client.request_builders]
119
+ def client_filename(self) -> str:
120
+ return self.clients[0].filename
121
+
122
+ def need_vendored_code(self, async_mode: bool) -> bool:
123
+ """Whether we need to vendor code in the _vendor.py file for this SDK"""
124
+ if self.has_abstract_operations:
125
+ return True
126
+ if async_mode:
127
+ return self.need_mixin_abc
128
+ return (
129
+ self.need_request_converter or self.need_format_url or self.need_mixin_abc
130
+ )
131
+
132
+ @property
133
+ def need_request_converter(self) -> bool:
134
+ return any(c for c in self.clients if c.need_request_converter)
135
+
136
+ @property
137
+ def need_format_url(self) -> bool:
138
+ return any(c for c in self.clients if c.need_format_url)
139
+
140
+ @property
141
+ def need_mixin_abc(self) -> bool:
142
+ return any(c for c in self.clients if c.has_mixin)
143
+
144
+ @property
145
+ def has_abstract_operations(self) -> bool:
146
+ return any(c for c in self.clients if c.has_abstract_operations)
147
+
148
+ @property
149
+ def operations_folder_name(self) -> str:
150
+ """Get the name of the operations folder that holds operations."""
151
+ name = "operations"
152
+ if self.options["version_tolerant"] and not any(
153
+ og
154
+ for client in self.clients
155
+ for og in client.operation_groups
156
+ if not og.is_mixin
157
+ ):
158
+ name = f"_{name}"
159
+ return name
160
+
161
+ @property
162
+ def description(self) -> str:
163
+ return self.clients[0].description
164
+
165
+ def lookup_type(self, schema_id: int) -> BaseType:
166
+ """Looks to see if the schema has already been created.
167
+
168
+ :param int schema_id: The yaml id of the schema
169
+ :return: If created, we return the created schema, otherwise, we throw.
170
+ :rtype: ~autorest.models.BaseType
171
+ :raises: KeyError if schema is not found
172
+ """
173
+ try:
174
+ return next(type for id, type in self.types_map.items() if id == schema_id)
175
+ except StopIteration:
176
+ raise KeyError(f"Couldn't find schema with id {schema_id}")
113
177
 
114
178
  @property
115
179
  def model_types(self) -> List[ModelType]:
@@ -179,15 +243,6 @@ class NamespaceModel:
179
243
  )
180
244
  self.model_types = sorted_object_schemas
181
245
 
182
- @property
183
- def is_legacy(self) -> bool:
184
- return _is_legacy(self.options)
185
-
186
- @property
187
- def rest_layer_name(self) -> str:
188
- """If we have a separate rest layer, what is its name?"""
189
- return "rest" if self.options["builders_visibility"] == "public" else "_rest"
190
-
191
246
  @property
192
247
  def models_filename(self) -> str:
193
248
  """Get the names of the model file(s)"""
@@ -195,10 +250,6 @@ class NamespaceModel:
195
250
  return "_models_py3"
196
251
  return "_models"
197
252
 
198
- @property
199
- def client_filename(self) -> str:
200
- return self.clients[0].filename
201
-
202
253
  @property
203
254
  def enums_filename(self) -> str:
204
255
  """The name of the enums file"""
@@ -206,41 +257,31 @@ class NamespaceModel:
206
257
  return f"_{self.clients[0].legacy_filename}_enums"
207
258
  return "_enums"
208
259
 
209
- def need_vendored_code(self, async_mode: bool) -> bool:
210
- """Whether we need to vendor code in the _vendor.py file for this SDK"""
211
- if self.has_abstract_operations:
212
- return True
213
- if async_mode:
214
- return self.need_mixin_abc
215
- return (
216
- self.need_request_converter or self.need_format_url or self.need_mixin_abc
217
- )
218
-
219
- @property
220
- def need_request_converter(self) -> bool:
221
- return any(c for c in self.clients if c.need_request_converter)
222
-
223
- @property
224
- def need_format_url(self) -> bool:
225
- return any(c for c in self.clients if c.need_format_url)
226
-
227
- @property
228
- def need_mixin_abc(self) -> bool:
229
- return any(c for c in self.clients if c.has_mixin)
230
-
231
260
  @property
232
- def has_abstract_operations(self) -> bool:
233
- return any(c for c in self.clients if c.has_abstract_operations)
261
+ def is_legacy(self) -> bool:
262
+ return _is_legacy(self.options)
234
263
 
235
264
  @property
236
- def operations_folder_name(self) -> str:
237
- """Get the name of the operations folder that holds operations."""
238
- name = "operations"
239
- if self.options["version_tolerant"] and not any(
240
- og
265
+ def need_typing_extensions(self) -> bool:
266
+ if self.options["models_mode"] and any(
267
+ isinstance(p.type, ConstantType)
268
+ and (p.optional or self.options["models_mode"] == "dpg")
269
+ for model in self.model_types
270
+ for p in model.properties
271
+ ):
272
+ return True
273
+ if any(
274
+ isinstance(parameter.type, ConstantType)
241
275
  for client in self.clients
242
276
  for og in client.operation_groups
243
- if not og.is_mixin
277
+ for op in og.operations
278
+ for parameter in op.parameters.method
244
279
  ):
245
- name = f"_{name}"
246
- return name
280
+ return True
281
+ if any(
282
+ isinstance(parameter.type, ConstantType)
283
+ for client in self.clients
284
+ for parameter in client.config.parameters.kwargs_to_pop
285
+ ):
286
+ return True
287
+ return False
@@ -6,10 +6,10 @@
6
6
  from typing import Any, Dict, List, Optional, TYPE_CHECKING
7
7
  import re
8
8
  from autorest.codegen.models.imports import FileImport, ImportType
9
- from .base_type import BaseType
9
+ from .base import BaseType
10
10
 
11
11
  if TYPE_CHECKING:
12
- from .code_model import NamespaceModel
12
+ from .code_model import CodeModel
13
13
  from .model_type import ModelType
14
14
 
15
15
 
@@ -23,10 +23,10 @@ class CombinedType(BaseType):
23
23
  def __init__(
24
24
  self,
25
25
  yaml_data: Dict[str, Any],
26
- namespace_model: "NamespaceModel",
26
+ code_model: "CodeModel",
27
27
  types: List[BaseType],
28
28
  ) -> None:
29
- super().__init__(yaml_data, namespace_model)
29
+ super().__init__(yaml_data, code_model)
30
30
  self.types = types # the types that this type is combining
31
31
 
32
32
  @property
@@ -105,12 +105,12 @@ class CombinedType(BaseType):
105
105
 
106
106
  @classmethod
107
107
  def from_yaml(
108
- cls, yaml_data: Dict[str, Any], namespace_model: "NamespaceModel"
108
+ cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
109
109
  ) -> "BaseType":
110
110
  from . import build_type
111
111
 
112
112
  return cls(
113
113
  yaml_data,
114
- namespace_model,
115
- [build_type(t, namespace_model) for t in yaml_data["types"]],
114
+ code_model,
115
+ [build_type(t, code_model) for t in yaml_data["types"]],
116
116
  )
@@ -5,12 +5,13 @@
5
5
  # --------------------------------------------------------------------------
6
6
  import logging
7
7
  from typing import Dict, Any, Optional, TYPE_CHECKING
8
- from .base_type import BaseType
9
- from .imports import FileImport
8
+ from .base import BaseType
9
+ from .imports import FileImport, ImportType, TypingSection
10
+ from .primitive_types import IntegerType, BinaryType, StringType, BooleanType
10
11
  from .utils import add_to_description
11
12
 
12
13
  if TYPE_CHECKING:
13
- from .code_model import NamespaceModel
14
+ from .code_model import CodeModel
14
15
 
15
16
  _LOGGER = logging.getLogger(__name__)
16
17
 
@@ -28,11 +29,11 @@ class ConstantType(BaseType):
28
29
  def __init__(
29
30
  self,
30
31
  yaml_data: Dict[str, Any],
31
- namespace_model: "NamespaceModel",
32
+ code_model: "CodeModel",
32
33
  value_type: BaseType,
33
34
  value: Optional[str],
34
35
  ) -> None:
35
- super().__init__(yaml_data=yaml_data, namespace_model=namespace_model)
36
+ super().__init__(yaml_data=yaml_data, code_model=code_model)
36
37
  self.value_type = value_type
37
38
  self.value = value
38
39
 
@@ -75,11 +76,21 @@ class ConstantType(BaseType):
75
76
  return self.value_type.docstring_type(**kwargs)
76
77
 
77
78
  def type_annotation(self, **kwargs: Any) -> str:
78
- return self.value_type.type_annotation(**kwargs)
79
+ return (
80
+ f"Literal[{self.get_declaration()}]"
81
+ if self._is_literal
82
+ else self.value_type.type_annotation(**kwargs)
83
+ )
84
+
85
+ @property
86
+ def _is_literal(self) -> bool:
87
+ return isinstance(
88
+ self.value_type, (IntegerType, BinaryType, StringType, BooleanType)
89
+ )
79
90
 
80
91
  @classmethod
81
92
  def from_yaml(
82
- cls, yaml_data: Dict[str, Any], namespace_model: "NamespaceModel"
93
+ cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
83
94
  ) -> "ConstantType":
84
95
  """Constructs a ConstantType from yaml data.
85
96
 
@@ -93,8 +104,8 @@ class ConstantType(BaseType):
93
104
 
94
105
  return cls(
95
106
  yaml_data=yaml_data,
96
- namespace_model=namespace_model,
97
- value_type=build_type(yaml_data["valueType"], namespace_model),
107
+ code_model=code_model,
108
+ value_type=build_type(yaml_data["valueType"], code_model),
98
109
  value=yaml_data["value"],
99
110
  )
100
111
 
@@ -112,11 +123,34 @@ class ConstantType(BaseType):
112
123
  description=description,
113
124
  )
114
125
 
115
- def imports(self, **kwargs: Any) -> FileImport:
126
+ def _imports_shared(self, **kwargs: Any):
116
127
  file_import = FileImport()
117
128
  file_import.merge(self.value_type.imports(**kwargs))
118
129
  return file_import
119
130
 
131
+ def imports_for_multiapi(self, **kwargs: Any) -> FileImport:
132
+ return self._imports_shared(**kwargs)
133
+
134
+ def imports(self, **kwargs: Any) -> FileImport:
135
+ file_import = self._imports_shared(**kwargs)
136
+ if self._is_literal:
137
+ file_import.add_import("sys", ImportType.STDLIB)
138
+ file_import.add_submodule_import(
139
+ "typing_extensions",
140
+ "Literal",
141
+ ImportType.BYVERSION,
142
+ TypingSection.REGULAR,
143
+ None,
144
+ (
145
+ (
146
+ (3, 8),
147
+ "typing",
148
+ "pylint: disable=no-name-in-module, ungrouped-imports",
149
+ ),
150
+ ),
151
+ )
152
+ return file_import
153
+
120
154
  @property
121
155
  def instance_check_template(self) -> str:
122
156
  return self.value_type.instance_check_template
@@ -17,10 +17,10 @@ from typing import (
17
17
  )
18
18
 
19
19
  from .imports import FileImport, ImportType, TypingSection
20
- from .base_type import BaseType
20
+ from .base import BaseType
21
21
 
22
22
  if TYPE_CHECKING:
23
- from .code_model import NamespaceModel
23
+ from .code_model import CodeModel
24
24
 
25
25
 
26
26
  class _CredentialPolicyBaseType:
@@ -29,11 +29,9 @@ class _CredentialPolicyBaseType:
29
29
  Inherited by our BearerTokenCredentialPolicy and AzureKeyCredentialPolicy types.
30
30
  """
31
31
 
32
- def __init__(
33
- self, yaml_data: Dict[str, Any], namespace_model: "NamespaceModel"
34
- ) -> None:
32
+ def __init__(self, yaml_data: Dict[str, Any], code_model: "CodeModel") -> None:
35
33
  self.yaml_data = yaml_data
36
- self.namespace_model = namespace_model
34
+ self.code_model = code_model
37
35
 
38
36
  @abstractmethod
39
37
  def call(self, async_mode: bool) -> str:
@@ -49,10 +47,10 @@ class BearerTokenCredentialPolicyType(_CredentialPolicyBaseType):
49
47
  def __init__(
50
48
  self,
51
49
  yaml_data: Dict[str, Any],
52
- namespace_model: "NamespaceModel",
50
+ code_model: "CodeModel",
53
51
  credential_scopes: List[str],
54
52
  ) -> None:
55
- super().__init__(yaml_data, namespace_model)
53
+ super().__init__(yaml_data, code_model)
56
54
  self.credential_scopes = credential_scopes
57
55
 
58
56
  def call(self, async_mode: bool) -> str:
@@ -61,9 +59,9 @@ class BearerTokenCredentialPolicyType(_CredentialPolicyBaseType):
61
59
 
62
60
  @classmethod
63
61
  def from_yaml(
64
- cls, yaml_data: Dict[str, Any], namespace_model: "NamespaceModel"
62
+ cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
65
63
  ) -> "BearerTokenCredentialPolicyType":
66
- return cls(yaml_data, namespace_model, yaml_data["credentialScopes"])
64
+ return cls(yaml_data, code_model, yaml_data["credentialScopes"])
67
65
 
68
66
 
69
67
  class ARMChallengeAuthenticationPolicyType(BearerTokenCredentialPolicyType):
@@ -76,9 +74,9 @@ class ARMChallengeAuthenticationPolicyType(BearerTokenCredentialPolicyType):
76
74
 
77
75
  class AzureKeyCredentialPolicyType(_CredentialPolicyBaseType):
78
76
  def __init__(
79
- self, yaml_data: Dict[str, Any], namespace_model: "NamespaceModel", key: str
77
+ self, yaml_data: Dict[str, Any], code_model: "CodeModel", key: str
80
78
  ) -> None:
81
- super().__init__(yaml_data, namespace_model)
79
+ super().__init__(yaml_data, code_model)
82
80
  self.key = key
83
81
 
84
82
  def call(self, async_mode: bool) -> str:
@@ -86,9 +84,9 @@ class AzureKeyCredentialPolicyType(_CredentialPolicyBaseType):
86
84
 
87
85
  @classmethod
88
86
  def from_yaml(
89
- cls, yaml_data: Dict[str, Any], namespace_model: "NamespaceModel"
87
+ cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
90
88
  ) -> "AzureKeyCredentialPolicyType":
91
- return cls(yaml_data, namespace_model, yaml_data["key"])
89
+ return cls(yaml_data, code_model, yaml_data["key"])
92
90
 
93
91
 
94
92
  CredentialPolicyType = TypeVar(
@@ -109,10 +107,10 @@ class CredentialType(
109
107
  def __init__(
110
108
  self,
111
109
  yaml_data: Dict[str, Any],
112
- namespace_model: "NamespaceModel",
110
+ code_model: "CodeModel",
113
111
  policy: CredentialPolicyType,
114
112
  ) -> None:
115
- super().__init__(yaml_data, namespace_model)
113
+ super().__init__(yaml_data, code_model)
116
114
  self.policy = policy
117
115
 
118
116
  def description(
@@ -140,15 +138,15 @@ class CredentialType(
140
138
 
141
139
  @classmethod
142
140
  def from_yaml(
143
- cls, yaml_data: Dict[str, Any], namespace_model: "NamespaceModel"
141
+ cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
144
142
  ) -> "CredentialType":
145
143
  from . import build_type
146
144
 
147
145
  return cls(
148
146
  yaml_data,
149
- namespace_model,
147
+ code_model,
150
148
  policy=cast(
151
- CredentialPolicyType, build_type(yaml_data["policy"], namespace_model)
149
+ CredentialPolicyType, build_type(yaml_data["policy"], code_model)
152
150
  ),
153
151
  )
154
152
 
@@ -4,11 +4,11 @@
4
4
  # license information.
5
5
  # --------------------------------------------------------------------------
6
6
  from typing import Any, Dict, Optional, TYPE_CHECKING, List
7
- from .base_type import BaseType
7
+ from .base import BaseType
8
8
  from .imports import FileImport, ImportType, TypingSection
9
9
 
10
10
  if TYPE_CHECKING:
11
- from .code_model import NamespaceModel
11
+ from .code_model import CodeModel
12
12
  from .model_type import ModelType
13
13
 
14
14
 
@@ -24,10 +24,10 @@ class DictionaryType(BaseType):
24
24
  def __init__(
25
25
  self,
26
26
  yaml_data: Dict[str, Any],
27
- namespace_model: "NamespaceModel",
27
+ code_model: "CodeModel",
28
28
  element_type: BaseType,
29
29
  ) -> None:
30
- super().__init__(yaml_data=yaml_data, namespace_model=namespace_model)
30
+ super().__init__(yaml_data=yaml_data, code_model=code_model)
31
31
  self.element_type = element_type
32
32
 
33
33
  @property
@@ -96,7 +96,7 @@ class DictionaryType(BaseType):
96
96
 
97
97
  @classmethod
98
98
  def from_yaml(
99
- cls, yaml_data: Dict[str, Any], namespace_model: "NamespaceModel"
99
+ cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
100
100
  ) -> "DictionaryType":
101
101
  """Constructs a DictionaryType from yaml data.
102
102
 
@@ -110,13 +110,11 @@ class DictionaryType(BaseType):
110
110
 
111
111
  from . import build_type # pylint: disable=import-outside-toplevel
112
112
 
113
- element_type = build_type(
114
- yaml_data=element_schema, namespace_model=namespace_model
115
- )
113
+ element_type = build_type(yaml_data=element_schema, code_model=code_model)
116
114
 
117
115
  return cls(
118
116
  yaml_data=yaml_data,
119
- namespace_model=namespace_model,
117
+ code_model=code_model,
120
118
  element_type=element_type,
121
119
  )
122
120