@autorest/python 6.13.16 → 6.13.18
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/__init__.py +4 -12
- package/autorest/_utils.py +5 -20
- package/autorest/black/__init__.py +1 -3
- package/autorest/codegen/__init__.py +29 -96
- package/autorest/codegen/models/__init__.py +1 -3
- package/autorest/codegen/models/base.py +2 -6
- package/autorest/codegen/models/base_builder.py +2 -6
- package/autorest/codegen/models/client.py +24 -86
- package/autorest/codegen/models/code_model.py +13 -53
- package/autorest/codegen/models/combined_type.py +3 -9
- package/autorest/codegen/models/constant_type.py +4 -14
- package/autorest/codegen/models/credential_types.py +11 -35
- package/autorest/codegen/models/dictionary_type.py +4 -12
- package/autorest/codegen/models/enum_type.py +10 -31
- package/autorest/codegen/models/imports.py +15 -41
- package/autorest/codegen/models/list_type.py +7 -23
- package/autorest/codegen/models/lro_operation.py +6 -18
- package/autorest/codegen/models/lro_paging_operation.py +1 -3
- package/autorest/codegen/models/model_type.py +21 -73
- package/autorest/codegen/models/operation.py +41 -139
- package/autorest/codegen/models/operation_group.py +21 -60
- package/autorest/codegen/models/paging_operation.py +13 -43
- package/autorest/codegen/models/parameter.py +16 -54
- package/autorest/codegen/models/parameter_list.py +27 -103
- package/autorest/codegen/models/primitive_types.py +15 -49
- package/autorest/codegen/models/property.py +8 -28
- package/autorest/codegen/models/request_builder.py +11 -39
- package/autorest/codegen/models/request_builder_parameter.py +4 -13
- package/autorest/codegen/models/response.py +16 -57
- package/autorest/codegen/serializers/__init__.py +46 -150
- package/autorest/codegen/serializers/builder_serializer.py +113 -402
- package/autorest/codegen/serializers/client_serializer.py +25 -78
- package/autorest/codegen/serializers/enum_serializer.py +1 -3
- package/autorest/codegen/serializers/general_serializer.py +6 -22
- package/autorest/codegen/serializers/import_serializer.py +13 -40
- package/autorest/codegen/serializers/metadata_serializer.py +7 -21
- package/autorest/codegen/serializers/model_init_serializer.py +1 -5
- package/autorest/codegen/serializers/model_serializer.py +13 -51
- package/autorest/codegen/serializers/operation_groups_serializer.py +1 -3
- package/autorest/codegen/serializers/operations_init_serializer.py +2 -8
- package/autorest/codegen/serializers/parameter_serializer.py +8 -26
- package/autorest/codegen/serializers/request_builders_serializer.py +1 -3
- package/autorest/codegen/serializers/sample_serializer.py +13 -39
- package/autorest/codegen/serializers/test_serializer.py +10 -30
- package/autorest/codegen/serializers/types_serializer.py +1 -3
- package/autorest/codegen/templates/serialization.py.jinja2 +1 -1
- package/autorest/jsonrpc/__init__.py +1 -3
- package/autorest/jsonrpc/server.py +3 -9
- package/autorest/jsonrpc/stdstream.py +4 -12
- package/autorest/m2r/__init__.py +2 -6
- package/autorest/m4reformatter/__init__.py +72 -237
- package/autorest/multiapi/__init__.py +4 -11
- package/autorest/multiapi/models/client.py +7 -21
- package/autorest/multiapi/models/code_model.py +9 -28
- package/autorest/multiapi/models/config.py +1 -3
- package/autorest/multiapi/models/global_parameters.py +6 -16
- package/autorest/multiapi/models/imports.py +5 -9
- package/autorest/multiapi/models/operation_mixin_group.py +5 -17
- package/autorest/multiapi/serializers/__init__.py +10 -31
- package/autorest/multiapi/serializers/import_serializer.py +8 -24
- package/autorest/multiapi/utils.py +2 -6
- package/autorest/multiclient/__init__.py +1 -3
- package/autorest/postprocess/__init__.py +9 -29
- package/autorest/postprocess/get_all.py +1 -3
- package/autorest/postprocess/venvtools.py +1 -3
- package/autorest/preprocess/__init__.py +43 -129
- package/install.py +2 -0
- package/package.json +1 -1
- package/prepare.py +3 -1
- package/requirements.txt +1 -1
- package/run_cadl.py +1 -3
- package/setup.py +25 -25
- package/start.py +2 -0
- package/venvtools.py +15 -10
|
@@ -49,15 +49,13 @@ class OperationGroup(BaseModel):
|
|
|
49
49
|
@property
|
|
50
50
|
def has_abstract_operations(self) -> bool:
|
|
51
51
|
return any(o for o in self.operations if o.abstract) or any(
|
|
52
|
-
operation_group.has_abstract_operations
|
|
53
|
-
for operation_group in self.operation_groups
|
|
52
|
+
operation_group.has_abstract_operations for operation_group in self.operation_groups
|
|
54
53
|
)
|
|
55
54
|
|
|
56
55
|
@property
|
|
57
56
|
def has_non_abstract_operations(self) -> bool:
|
|
58
57
|
return any(o for o in self.operations if not o.abstract) or any(
|
|
59
|
-
operation_group.has_non_abstract_operations
|
|
60
|
-
for operation_group in self.operation_groups
|
|
58
|
+
operation_group.has_non_abstract_operations for operation_group in self.operation_groups
|
|
61
59
|
)
|
|
62
60
|
|
|
63
61
|
@property
|
|
@@ -71,15 +69,11 @@ class OperationGroup(BaseModel):
|
|
|
71
69
|
file_import = FileImport(self.code_model)
|
|
72
70
|
relative_path = ".." if async_mode else "."
|
|
73
71
|
for operation in self.operations:
|
|
74
|
-
file_import.merge(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
) and self.code_model.options["models_mode"] == "msrest":
|
|
80
|
-
file_import.add_submodule_import(
|
|
81
|
-
relative_path, "models", ImportType.LOCAL, alias="_models"
|
|
82
|
-
)
|
|
72
|
+
file_import.merge(operation.imports_for_multiapi(async_mode, relative_path=relative_path))
|
|
73
|
+
if (self.code_model.model_types or self.code_model.enums) and self.code_model.options[
|
|
74
|
+
"models_mode"
|
|
75
|
+
] == "msrest":
|
|
76
|
+
file_import.add_submodule_import(relative_path, "models", ImportType.LOCAL, alias="_models")
|
|
83
77
|
return file_import
|
|
84
78
|
|
|
85
79
|
@property
|
|
@@ -103,13 +97,9 @@ class OperationGroup(BaseModel):
|
|
|
103
97
|
def imports(self, async_mode: bool) -> FileImport:
|
|
104
98
|
file_import = FileImport(self.code_model)
|
|
105
99
|
|
|
106
|
-
relative_path = ("..." if async_mode else "..") + (
|
|
107
|
-
"." if self.client.is_subclient else ""
|
|
108
|
-
)
|
|
100
|
+
relative_path = ("..." if async_mode else "..") + ("." if self.client.is_subclient else "")
|
|
109
101
|
for operation in self.operations:
|
|
110
|
-
file_import.merge(
|
|
111
|
-
operation.imports(async_mode, relative_path=relative_path)
|
|
112
|
-
)
|
|
102
|
+
file_import.merge(operation.imports(async_mode, relative_path=relative_path))
|
|
113
103
|
if not self.code_model.options["combine_operation_files"]:
|
|
114
104
|
for og in self.operation_groups:
|
|
115
105
|
file_import.add_submodule_import(
|
|
@@ -123,27 +113,17 @@ class OperationGroup(BaseModel):
|
|
|
123
113
|
and self.code_model.options["models_mode"] == "msrest"
|
|
124
114
|
and not self.is_mixin
|
|
125
115
|
):
|
|
126
|
-
file_import.add_submodule_import(
|
|
127
|
-
relative_path, "models", ImportType.LOCAL, alias="_models"
|
|
128
|
-
)
|
|
116
|
+
file_import.add_submodule_import(relative_path, "models", ImportType.LOCAL, alias="_models")
|
|
129
117
|
if self.code_model.need_mixin_abc:
|
|
130
|
-
file_import.add_submodule_import(
|
|
131
|
-
".._vendor", f"{self.client.name}MixinABC", ImportType.LOCAL
|
|
132
|
-
)
|
|
118
|
+
file_import.add_submodule_import(".._vendor", f"{self.client.name}MixinABC", ImportType.LOCAL)
|
|
133
119
|
if self.has_abstract_operations:
|
|
134
|
-
file_import.add_submodule_import(
|
|
135
|
-
".._vendor", "raise_if_not_implemented", ImportType.LOCAL
|
|
136
|
-
)
|
|
120
|
+
file_import.add_submodule_import(".._vendor", "raise_if_not_implemented", ImportType.LOCAL)
|
|
137
121
|
if all(o.abstract for o in self.operations):
|
|
138
122
|
return file_import
|
|
139
|
-
file_import.add_submodule_import(
|
|
140
|
-
"typing", "TypeVar", ImportType.STDLIB, TypingSection.CONDITIONAL
|
|
141
|
-
)
|
|
123
|
+
file_import.add_submodule_import("typing", "TypeVar", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
142
124
|
file_import.define_mypy_type("T", "TypeVar('T')")
|
|
143
125
|
type_value = "Optional[Callable[[PipelineResponse[HttpRequest, {}HttpResponse], T, Dict[str, Any]], Any]]"
|
|
144
|
-
file_import.define_mypy_type(
|
|
145
|
-
"ClsType", type_value.format(""), type_value.format("Async")
|
|
146
|
-
)
|
|
126
|
+
file_import.define_mypy_type("ClsType", type_value.format(""), type_value.format("Async"))
|
|
147
127
|
return file_import
|
|
148
128
|
|
|
149
129
|
@property
|
|
@@ -160,44 +140,27 @@ class OperationGroup(BaseModel):
|
|
|
160
140
|
for operation_group in self.operation_groups:
|
|
161
141
|
for operation in operation_group.operations:
|
|
162
142
|
if isinstance(operation, (LROOperation, LROPagingOperation)):
|
|
163
|
-
operation.initial_operation = self.lookup_operation(
|
|
164
|
-
id(operation.yaml_data["initialOperation"])
|
|
165
|
-
)
|
|
143
|
+
operation.initial_operation = self.lookup_operation(id(operation.yaml_data["initialOperation"]))
|
|
166
144
|
|
|
167
145
|
def lookup_operation(self, operation_id: int) -> "OperationType":
|
|
168
146
|
try:
|
|
169
|
-
return next(
|
|
170
|
-
o
|
|
171
|
-
for og in self.operation_groups
|
|
172
|
-
for o in og.operations
|
|
173
|
-
if id(o.yaml_data) == operation_id
|
|
174
|
-
)
|
|
147
|
+
return next(o for og in self.operation_groups for o in og.operations if id(o.yaml_data) == operation_id)
|
|
175
148
|
except StopIteration as exc:
|
|
176
149
|
raise KeyError(f"No operation with id {operation_id} found.") from exc
|
|
177
150
|
|
|
178
151
|
@property
|
|
179
152
|
def lro_operations(self) -> List["OperationType"]:
|
|
180
|
-
return [
|
|
181
|
-
operation
|
|
182
|
-
for operation in self.operations
|
|
183
|
-
if operation.operation_type in ("lro", "lropaging")
|
|
184
|
-
] + [
|
|
185
|
-
operation
|
|
186
|
-
for operation_group in self.operation_groups
|
|
187
|
-
for operation in operation_group.lro_operations
|
|
153
|
+
return [operation for operation in self.operations if operation.operation_type in ("lro", "lropaging")] + [
|
|
154
|
+
operation for operation_group in self.operation_groups for operation in operation_group.lro_operations
|
|
188
155
|
]
|
|
189
156
|
|
|
190
157
|
@property
|
|
191
158
|
def has_operations(self) -> bool:
|
|
192
|
-
return any(
|
|
193
|
-
operation_group.has_operations for operation_group in self.operation_groups
|
|
194
|
-
) or bool(self.operations)
|
|
159
|
+
return any(operation_group.has_operations for operation_group in self.operation_groups) or bool(self.operations)
|
|
195
160
|
|
|
196
161
|
@property
|
|
197
162
|
def has_form_data_body(self) -> bool:
|
|
198
|
-
operations = self.operations + [
|
|
199
|
-
o for og in self.operation_groups for o in og.operations
|
|
200
|
-
]
|
|
163
|
+
operations = self.operations + [o for og in self.operation_groups for o in og.operations]
|
|
201
164
|
return any(operation.has_form_data_body for operation in operations)
|
|
202
165
|
|
|
203
166
|
@classmethod
|
|
@@ -207,9 +170,7 @@ class OperationGroup(BaseModel):
|
|
|
207
170
|
code_model: "CodeModel",
|
|
208
171
|
client: "Client",
|
|
209
172
|
) -> "OperationGroup":
|
|
210
|
-
operations = [
|
|
211
|
-
get_operation(o, code_model, client) for o in yaml_data["operations"]
|
|
212
|
-
]
|
|
173
|
+
operations = [get_operation(o, code_model, client) for o in yaml_data["operations"]]
|
|
213
174
|
api_versions: OrderedSet[str] = {}
|
|
214
175
|
for operation in operations:
|
|
215
176
|
for api_version in operation.api_versions:
|
|
@@ -22,9 +22,7 @@ if TYPE_CHECKING:
|
|
|
22
22
|
from .code_model import CodeModel
|
|
23
23
|
from .client import Client
|
|
24
24
|
|
|
25
|
-
PagingResponseType = TypeVar(
|
|
26
|
-
"PagingResponseType", bound=Union[PagingResponse, LROPagingResponse]
|
|
27
|
-
)
|
|
25
|
+
PagingResponseType = TypeVar("PagingResponseType", bound=Union[PagingResponse, LROPagingResponse])
|
|
28
26
|
|
|
29
27
|
|
|
30
28
|
class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
@@ -53,41 +51,25 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
53
51
|
exceptions=exceptions,
|
|
54
52
|
overloads=overloads,
|
|
55
53
|
)
|
|
56
|
-
self.next_request_builder: Optional[
|
|
57
|
-
Union[RequestBuilder, OverloadedRequestBuilder]
|
|
58
|
-
] = (
|
|
54
|
+
self.next_request_builder: Optional[Union[RequestBuilder, OverloadedRequestBuilder]] = (
|
|
59
55
|
get_request_builder(self.yaml_data["nextOperation"], code_model, client)
|
|
60
56
|
if self.yaml_data.get("nextOperation")
|
|
61
57
|
else None
|
|
62
58
|
)
|
|
63
59
|
self.override_success_response_to_200 = override_success_response_to_200
|
|
64
|
-
self.pager_sync: str = (
|
|
65
|
-
|
|
66
|
-
or f"{self.code_model.core_library}.paging.ItemPaged"
|
|
67
|
-
)
|
|
68
|
-
self.pager_async: str = (
|
|
69
|
-
yaml_data.get("pagerAsync")
|
|
70
|
-
or f"{self.code_model.core_library}.paging.AsyncItemPaged"
|
|
71
|
-
)
|
|
60
|
+
self.pager_sync: str = yaml_data.get("pagerSync") or f"{self.code_model.core_library}.paging.ItemPaged"
|
|
61
|
+
self.pager_async: str = yaml_data.get("pagerAsync") or f"{self.code_model.core_library}.paging.AsyncItemPaged"
|
|
72
62
|
|
|
73
63
|
def _get_attr_name(self, wire_name: str) -> str:
|
|
74
64
|
response_type = self.responses[0].type
|
|
75
65
|
if not response_type:
|
|
76
|
-
raise ValueError(
|
|
77
|
-
f"Can't find a matching property in response for {wire_name}"
|
|
78
|
-
)
|
|
66
|
+
raise ValueError(f"Can't find a matching property in response for {wire_name}")
|
|
79
67
|
if response_type.type == "list":
|
|
80
68
|
response_type = cast(ListType, response_type).element_type
|
|
81
69
|
try:
|
|
82
|
-
return next(
|
|
83
|
-
p.client_name
|
|
84
|
-
for p in cast(ModelType, response_type).properties
|
|
85
|
-
if p.wire_name == wire_name
|
|
86
|
-
)
|
|
70
|
+
return next(p.client_name for p in cast(ModelType, response_type).properties if p.wire_name == wire_name)
|
|
87
71
|
except StopIteration as exc:
|
|
88
|
-
raise ValueError(
|
|
89
|
-
f"Can't find a matching property in response for {wire_name}"
|
|
90
|
-
) from exc
|
|
72
|
+
raise ValueError(f"Can't find a matching property in response for {wire_name}") from exc
|
|
91
73
|
|
|
92
74
|
def get_pager(self, async_mode: bool) -> str:
|
|
93
75
|
return self.responses[0].get_pager(async_mode)
|
|
@@ -115,9 +97,7 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
115
97
|
try:
|
|
116
98
|
item_type_yaml = self.yaml_data["itemType"]
|
|
117
99
|
except KeyError as e:
|
|
118
|
-
raise ValueError(
|
|
119
|
-
"Only call this for DPG paging model deserialization"
|
|
120
|
-
) from e
|
|
100
|
+
raise ValueError("Only call this for DPG paging model deserialization") from e
|
|
121
101
|
return cast(ModelType, self.code_model.types_map[id(item_type_yaml)])
|
|
122
102
|
|
|
123
103
|
@property
|
|
@@ -130,13 +110,9 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
130
110
|
def _imports_shared(self, async_mode: bool, **kwargs: Any) -> FileImport:
|
|
131
111
|
file_import = super()._imports_shared(async_mode, **kwargs)
|
|
132
112
|
if async_mode:
|
|
133
|
-
file_import.add_submodule_import(
|
|
134
|
-
"typing", "AsyncIterable", ImportType.STDLIB, TypingSection.CONDITIONAL
|
|
135
|
-
)
|
|
113
|
+
file_import.add_submodule_import("typing", "AsyncIterable", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
136
114
|
else:
|
|
137
|
-
file_import.add_submodule_import(
|
|
138
|
-
"typing", "Iterable", ImportType.STDLIB, TypingSection.CONDITIONAL
|
|
139
|
-
)
|
|
115
|
+
file_import.add_submodule_import("typing", "Iterable", ImportType.STDLIB, TypingSection.CONDITIONAL)
|
|
140
116
|
if (
|
|
141
117
|
self.next_request_builder
|
|
142
118
|
and self.code_model.options["builders_visibility"] == "embedded"
|
|
@@ -161,9 +137,7 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
161
137
|
ImportType.SDKCORE,
|
|
162
138
|
)
|
|
163
139
|
if self.next_request_builder:
|
|
164
|
-
file_import.merge(
|
|
165
|
-
self.get_request_builder_import(self.next_request_builder, async_mode)
|
|
166
|
-
)
|
|
140
|
+
file_import.merge(self.get_request_builder_import(self.next_request_builder, async_mode))
|
|
167
141
|
elif any(p.is_api_version for p in self.client.parameters):
|
|
168
142
|
file_import.add_import("urllib.parse", ImportType.STDLIB)
|
|
169
143
|
file_import.add_submodule_import(
|
|
@@ -174,12 +148,8 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
174
148
|
if self.code_model.options["models_mode"] == "dpg":
|
|
175
149
|
relative_path = "..." if async_mode else ".."
|
|
176
150
|
file_import.merge(self.item_type.imports(**kwargs))
|
|
177
|
-
if self.default_error_deserialization or any(
|
|
178
|
-
|
|
179
|
-
):
|
|
180
|
-
file_import.add_submodule_import(
|
|
181
|
-
f"{relative_path}_model_base", "_deserialize", ImportType.LOCAL
|
|
182
|
-
)
|
|
151
|
+
if self.default_error_deserialization or any(r.type for r in self.responses):
|
|
152
|
+
file_import.add_submodule_import(f"{relative_path}_model_base", "_deserialize", ImportType.LOCAL)
|
|
183
153
|
return file_import
|
|
184
154
|
|
|
185
155
|
|
|
@@ -51,9 +51,7 @@ class ParameterDelimeter(str, Enum):
|
|
|
51
51
|
COMMA = "comma"
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
class _ParameterBase(
|
|
55
|
-
BaseModel, abc.ABC
|
|
56
|
-
): # pylint: disable=too-many-instance-attributes
|
|
54
|
+
class _ParameterBase(BaseModel, abc.ABC): # pylint: disable=too-many-instance-attributes
|
|
57
55
|
"""Base class for all parameters"""
|
|
58
56
|
|
|
59
57
|
def __init__(
|
|
@@ -66,6 +64,7 @@ class _ParameterBase(
|
|
|
66
64
|
self.wire_name: str = yaml_data.get("wireName", "")
|
|
67
65
|
self.client_name: str = self.yaml_data["clientName"]
|
|
68
66
|
self.optional: bool = self.yaml_data["optional"]
|
|
67
|
+
self.implementation: str = yaml_data.get("implementation", None)
|
|
69
68
|
self.location: ParameterLocation = self.yaml_data["location"]
|
|
70
69
|
self.client_default_value = self.yaml_data.get("clientDefaultValue", None)
|
|
71
70
|
self.in_docstring = self.yaml_data.get("inDocstring", True)
|
|
@@ -76,9 +75,7 @@ class _ParameterBase(
|
|
|
76
75
|
self.grouped_by: Optional[str] = self.yaml_data.get("groupedBy")
|
|
77
76
|
# property matching property name to parameter name for grouping params
|
|
78
77
|
# and flattened body params
|
|
79
|
-
self.property_to_parameter_name: Optional[Dict[str, str]] = self.yaml_data.get(
|
|
80
|
-
"propertyToParameterName"
|
|
81
|
-
)
|
|
78
|
+
self.property_to_parameter_name: Optional[Dict[str, str]] = self.yaml_data.get("propertyToParameterName")
|
|
82
79
|
self.flattened: bool = self.yaml_data.get("flattened", False)
|
|
83
80
|
self.in_flattened_body: bool = self.yaml_data.get("inFlattenedBody", False)
|
|
84
81
|
self.grouper: bool = self.yaml_data.get("grouper", False)
|
|
@@ -86,9 +83,7 @@ class _ParameterBase(
|
|
|
86
83
|
self.added_on: Optional[str] = self.yaml_data.get("addedOn")
|
|
87
84
|
self.is_api_version: bool = self.yaml_data.get("isApiVersion", False)
|
|
88
85
|
self.in_overload: bool = self.yaml_data.get("inOverload", False)
|
|
89
|
-
self.default_to_unset_sentinel: bool = self.yaml_data.get(
|
|
90
|
-
"defaultToUnsetSentinel", False
|
|
91
|
-
)
|
|
86
|
+
self.default_to_unset_sentinel: bool = self.yaml_data.get("defaultToUnsetSentinel", False)
|
|
92
87
|
self.hide_in_method: bool = self.yaml_data.get("hideInMethod", False)
|
|
93
88
|
|
|
94
89
|
def get_declaration(self, value: Any = None) -> Any:
|
|
@@ -104,9 +99,7 @@ class _ParameterBase(
|
|
|
104
99
|
Checking to see if it's required, because if not, we don't consider it
|
|
105
100
|
a constant because it can have a value of None.
|
|
106
101
|
"""
|
|
107
|
-
return (not self.optional or self.is_api_version) and isinstance(
|
|
108
|
-
self.type, ConstantType
|
|
109
|
-
)
|
|
102
|
+
return (not self.optional or self.is_api_version) and isinstance(self.type, ConstantType)
|
|
110
103
|
|
|
111
104
|
@property
|
|
112
105
|
def description(self) -> str:
|
|
@@ -170,7 +163,7 @@ class _ParameterBase(
|
|
|
170
163
|
file_import = FileImport(self.code_model)
|
|
171
164
|
if self.optional and self.client_default_value is None:
|
|
172
165
|
file_import.add_submodule_import("typing", "Optional", ImportType.STDLIB)
|
|
173
|
-
if self.added_on:
|
|
166
|
+
if self.added_on and self.implementation != "Client":
|
|
174
167
|
file_import.add_submodule_import(
|
|
175
168
|
f"{'.' if async_mode else ''}.._validation",
|
|
176
169
|
"api_version_validation",
|
|
@@ -200,9 +193,7 @@ class _ParameterBase(
|
|
|
200
193
|
|
|
201
194
|
def imports_for_multiapi(self, async_mode: bool, **kwargs: Any) -> FileImport:
|
|
202
195
|
file_import = self._imports_shared(async_mode, **kwargs)
|
|
203
|
-
file_import.merge(
|
|
204
|
-
self.type.imports_for_multiapi(async_mode=async_mode, **kwargs)
|
|
205
|
-
)
|
|
196
|
+
file_import.merge(self.type.imports_for_multiapi(async_mode=async_mode, **kwargs))
|
|
206
197
|
return file_import
|
|
207
198
|
|
|
208
199
|
@property
|
|
@@ -211,19 +202,11 @@ class _ParameterBase(
|
|
|
211
202
|
|
|
212
203
|
@property
|
|
213
204
|
def description_keyword(self) -> str:
|
|
214
|
-
return
|
|
215
|
-
"param"
|
|
216
|
-
if self.method_location == ParameterMethodLocation.POSITIONAL
|
|
217
|
-
else "keyword"
|
|
218
|
-
)
|
|
205
|
+
return "param" if self.method_location == ParameterMethodLocation.POSITIONAL else "keyword"
|
|
219
206
|
|
|
220
207
|
@property
|
|
221
208
|
def docstring_type_keyword(self) -> str:
|
|
222
|
-
return
|
|
223
|
-
"type"
|
|
224
|
-
if self.method_location == ParameterMethodLocation.POSITIONAL
|
|
225
|
-
else "paramtype"
|
|
226
|
-
)
|
|
209
|
+
return "type" if self.method_location == ParameterMethodLocation.POSITIONAL else "paramtype"
|
|
227
210
|
|
|
228
211
|
@property
|
|
229
212
|
@abc.abstractmethod
|
|
@@ -243,10 +226,7 @@ class BodyParameter(_ParameterBase):
|
|
|
243
226
|
|
|
244
227
|
@property
|
|
245
228
|
def entries(self) -> List["BodyParameter"]:
|
|
246
|
-
return [
|
|
247
|
-
BodyParameter.from_yaml(e, self.code_model)
|
|
248
|
-
for e in self.yaml_data.get("entries", [])
|
|
249
|
-
]
|
|
229
|
+
return [BodyParameter.from_yaml(e, self.code_model) for e in self.yaml_data.get("entries", [])]
|
|
250
230
|
|
|
251
231
|
@property
|
|
252
232
|
def is_form_data(self) -> bool:
|
|
@@ -261,11 +241,7 @@ class BodyParameter(_ParameterBase):
|
|
|
261
241
|
|
|
262
242
|
@property
|
|
263
243
|
def method_location(self) -> ParameterMethodLocation:
|
|
264
|
-
return
|
|
265
|
-
ParameterMethodLocation.KWARG
|
|
266
|
-
if self.constant
|
|
267
|
-
else ParameterMethodLocation.POSITIONAL
|
|
268
|
-
)
|
|
244
|
+
return ParameterMethodLocation.KWARG if self.constant else ParameterMethodLocation.POSITIONAL
|
|
269
245
|
|
|
270
246
|
@property
|
|
271
247
|
def in_method_signature(self) -> bool:
|
|
@@ -302,9 +278,7 @@ class BodyParameter(_ParameterBase):
|
|
|
302
278
|
return file_import
|
|
303
279
|
|
|
304
280
|
@classmethod
|
|
305
|
-
def from_yaml(
|
|
306
|
-
cls, yaml_data: Dict[str, Any], code_model: "CodeModel"
|
|
307
|
-
) -> "BodyParameter":
|
|
281
|
+
def from_yaml(cls, yaml_data: Dict[str, Any], code_model: "CodeModel") -> "BodyParameter":
|
|
308
282
|
return cls(
|
|
309
283
|
yaml_data=yaml_data,
|
|
310
284
|
code_model=code_model,
|
|
@@ -312,9 +286,7 @@ class BodyParameter(_ParameterBase):
|
|
|
312
286
|
)
|
|
313
287
|
|
|
314
288
|
|
|
315
|
-
EntryBodyParameterType = TypeVar(
|
|
316
|
-
"EntryBodyParameterType", bound=Union[BodyParameter, "RequestBuilderBodyParameter"]
|
|
317
|
-
)
|
|
289
|
+
EntryBodyParameterType = TypeVar("EntryBodyParameterType", bound=Union[BodyParameter, "RequestBuilderBodyParameter"])
|
|
318
290
|
|
|
319
291
|
|
|
320
292
|
class Parameter(_ParameterBase):
|
|
@@ -328,7 +300,6 @@ class Parameter(_ParameterBase):
|
|
|
328
300
|
) -> None:
|
|
329
301
|
super().__init__(yaml_data, code_model, type=type)
|
|
330
302
|
|
|
331
|
-
self.implementation: str = yaml_data["implementation"]
|
|
332
303
|
self.skip_url_encoding: bool = self.yaml_data.get("skipUrlEncoding", False)
|
|
333
304
|
self.explode: bool = self.yaml_data.get("explode", False)
|
|
334
305
|
self.in_overriden: bool = self.yaml_data.get("inOverriden", False)
|
|
@@ -337,10 +308,7 @@ class Parameter(_ParameterBase):
|
|
|
337
308
|
|
|
338
309
|
@property
|
|
339
310
|
def hide_in_operation_signature(self) -> bool:
|
|
340
|
-
if
|
|
341
|
-
self.code_model.options["version_tolerant"]
|
|
342
|
-
and self.client_name == "maxpagesize"
|
|
343
|
-
):
|
|
311
|
+
if self.code_model.options["version_tolerant"] and self.client_name == "maxpagesize":
|
|
344
312
|
return True
|
|
345
313
|
return False
|
|
346
314
|
|
|
@@ -382,10 +350,7 @@ class Parameter(_ParameterBase):
|
|
|
382
350
|
ParameterLocation.HEADER,
|
|
383
351
|
ParameterLocation.QUERY,
|
|
384
352
|
)
|
|
385
|
-
if
|
|
386
|
-
self.code_model.options["only_path_and_body_params_positional"]
|
|
387
|
-
and query_or_header
|
|
388
|
-
):
|
|
353
|
+
if self.code_model.options["only_path_and_body_params_positional"] and query_or_header:
|
|
389
354
|
return ParameterMethodLocation.KEYWORD_ONLY
|
|
390
355
|
return ParameterMethodLocation.POSITIONAL
|
|
391
356
|
|
|
@@ -411,10 +376,7 @@ class ClientParameter(Parameter):
|
|
|
411
376
|
return ParameterMethodLocation.KWARG
|
|
412
377
|
if (
|
|
413
378
|
self.is_host
|
|
414
|
-
and (
|
|
415
|
-
self.code_model.options["version_tolerant"]
|
|
416
|
-
or self.code_model.options["low_level_client"]
|
|
417
|
-
)
|
|
379
|
+
and (self.code_model.options["version_tolerant"] or self.code_model.options["low_level_client"])
|
|
418
380
|
and not self.code_model.options["azure_arm"]
|
|
419
381
|
):
|
|
420
382
|
# this means i am the base url
|