@autorest/python 6.13.16 → 6.13.17
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/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 +40 -126
- 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
|
@@ -25,11 +25,7 @@ class OperationsInitSerializer:
|
|
|
25
25
|
|
|
26
26
|
def operation_group_imports(self) -> List[str]:
|
|
27
27
|
def _get_filename(operation_group: OperationGroup) -> str:
|
|
28
|
-
return
|
|
29
|
-
"_operations"
|
|
30
|
-
if self.code_model.options["combine_operation_files"]
|
|
31
|
-
else operation_group.filename
|
|
32
|
-
)
|
|
28
|
+
return "_operations" if self.code_model.options["combine_operation_files"] else operation_group.filename
|
|
33
29
|
|
|
34
30
|
return [
|
|
35
31
|
f"from .{_get_filename(og)} import {og.class_name}"
|
|
@@ -38,9 +34,7 @@ class OperationsInitSerializer:
|
|
|
38
34
|
]
|
|
39
35
|
|
|
40
36
|
def serialize(self) -> str:
|
|
41
|
-
operation_group_init_template = self.env.get_template(
|
|
42
|
-
"operations_folder_init.py.jinja2"
|
|
43
|
-
)
|
|
37
|
+
operation_group_init_template = self.env.get_template("operations_folder_init.py.jinja2")
|
|
44
38
|
|
|
45
39
|
return operation_group_init_template.render(
|
|
46
40
|
code_model=self.code_model,
|
|
@@ -121,9 +121,7 @@ class ParameterSerializer:
|
|
|
121
121
|
[
|
|
122
122
|
' "{}": {},'.format(
|
|
123
123
|
path_parameter.wire_name,
|
|
124
|
-
ParameterSerializer.serialize_parameter(
|
|
125
|
-
path_parameter, serializer_name
|
|
126
|
-
),
|
|
124
|
+
ParameterSerializer.serialize_parameter(path_parameter, serializer_name),
|
|
127
125
|
)
|
|
128
126
|
for path_parameter in parameters
|
|
129
127
|
]
|
|
@@ -172,9 +170,7 @@ class ParameterSerializer:
|
|
|
172
170
|
|
|
173
171
|
def append_pop_kwarg(key: str, pop_type: PopKwargType) -> None:
|
|
174
172
|
if PopKwargType.CASE_INSENSITIVE == pop_type:
|
|
175
|
-
retval.append(
|
|
176
|
-
f'_{key} = case_insensitive_dict(kwargs.pop("{key}", {{}}) or {{}})'
|
|
177
|
-
)
|
|
173
|
+
retval.append(f'_{key} = case_insensitive_dict(kwargs.pop("{key}", {{}}) or {{}})')
|
|
178
174
|
elif PopKwargType.SIMPLE == pop_type:
|
|
179
175
|
retval.append(f'_{key} = kwargs.pop("{key}", {{}}) or {{}}')
|
|
180
176
|
|
|
@@ -189,35 +185,21 @@ class ParameterSerializer:
|
|
|
189
185
|
default_value = f"self._config.{kwarg.client_name}"
|
|
190
186
|
else:
|
|
191
187
|
default_value = kwarg.client_default_value_declaration
|
|
192
|
-
if check_kwarg_dict and (
|
|
193
|
-
kwarg.location
|
|
194
|
-
in [ParameterLocation.HEADER, ParameterLocation.QUERY]
|
|
195
|
-
):
|
|
196
|
-
kwarg_dict = (
|
|
197
|
-
"headers"
|
|
198
|
-
if kwarg.location == ParameterLocation.HEADER
|
|
199
|
-
else "params"
|
|
200
|
-
)
|
|
188
|
+
if check_kwarg_dict and (kwarg.location in [ParameterLocation.HEADER, ParameterLocation.QUERY]):
|
|
189
|
+
kwarg_dict = "headers" if kwarg.location == ParameterLocation.HEADER else "params"
|
|
201
190
|
if (
|
|
202
191
|
kwarg.client_name == "api_version"
|
|
203
192
|
and kwarg.code_model.options["multiapi"]
|
|
204
193
|
and operation_name is not None
|
|
205
194
|
):
|
|
206
|
-
default_value =
|
|
207
|
-
|
|
208
|
-
)
|
|
209
|
-
default_value = (
|
|
210
|
-
f"_{kwarg_dict}.pop('{kwarg.wire_name}', {default_value})"
|
|
211
|
-
)
|
|
195
|
+
default_value = f"self._api_version{operation_name} or {default_value}"
|
|
196
|
+
default_value = f"_{kwarg_dict}.pop('{kwarg.wire_name}', {default_value})"
|
|
212
197
|
|
|
213
198
|
retval.append(
|
|
214
|
-
f"{kwarg.client_name}: {type_annot} = kwargs.pop('{kwarg.client_name}', "
|
|
215
|
-
+ f"{default_value})"
|
|
199
|
+
f"{kwarg.client_name}: {type_annot} = kwargs.pop('{kwarg.client_name}', " + f"{default_value})"
|
|
216
200
|
)
|
|
217
201
|
else:
|
|
218
|
-
retval.append(
|
|
219
|
-
f"{kwarg.client_name}: {type_annot} = kwargs.pop('{kwarg.client_name}')"
|
|
220
|
-
)
|
|
202
|
+
retval.append(f"{kwarg.client_name}: {type_annot} = kwargs.pop('{kwarg.client_name}')")
|
|
221
203
|
return retval
|
|
222
204
|
|
|
223
205
|
@staticmethod
|
|
@@ -48,7 +48,5 @@ class RequestBuildersSerializer(BaseSerializer):
|
|
|
48
48
|
imports=FileImportSerializer(
|
|
49
49
|
self.imports,
|
|
50
50
|
),
|
|
51
|
-
request_builder_serializer=RequestBuilderSerializer(
|
|
52
|
-
self.code_model, async_mode=False
|
|
53
|
-
),
|
|
51
|
+
request_builder_serializer=RequestBuilderSerializer(self.code_model, async_mode=False),
|
|
54
52
|
)
|
|
@@ -42,31 +42,23 @@ class SampleSerializer(BaseSerializer):
|
|
|
42
42
|
self.operation = operation
|
|
43
43
|
self.sample = sample
|
|
44
44
|
self.file_name = file_name
|
|
45
|
-
self.sample_params = {
|
|
46
|
-
to_snake_case(k): v for k, v in sample.get("parameters", {}).items()
|
|
47
|
-
}
|
|
45
|
+
self.sample_params = {to_snake_case(k): v for k, v in sample.get("parameters", {}).items()}
|
|
48
46
|
|
|
49
47
|
def _imports(self) -> FileImportSerializer:
|
|
50
48
|
imports = FileImport(self.code_model)
|
|
51
|
-
namespace_from_package_name = get_namespace_from_package_name(
|
|
52
|
-
|
|
53
|
-
)
|
|
54
|
-
namespace_config = get_namespace_config(
|
|
55
|
-
self.code_model.namespace, self.code_model.options["multiapi"]
|
|
56
|
-
)
|
|
49
|
+
namespace_from_package_name = get_namespace_from_package_name(self.code_model.options["package_name"])
|
|
50
|
+
namespace_config = get_namespace_config(self.code_model.namespace, self.code_model.options["multiapi"])
|
|
57
51
|
namespace = namespace_from_package_name or namespace_config
|
|
58
52
|
# mainly for "azure-mgmt-rdbms"
|
|
59
|
-
if not self.code_model.options["multiapi"] and namespace_config.count(
|
|
53
|
+
if not self.code_model.options["multiapi"] and namespace_config.count(".") > namespace_from_package_name.count(
|
|
60
54
|
"."
|
|
61
|
-
)
|
|
55
|
+
):
|
|
62
56
|
namespace = namespace_config
|
|
63
57
|
client = self.code_model.clients[0]
|
|
64
58
|
imports.add_submodule_import(namespace, client.name, ImportType.LOCAL)
|
|
65
59
|
credential_type = getattr(client.credential, "type", None)
|
|
66
60
|
if isinstance(credential_type, TokenCredentialType):
|
|
67
|
-
imports.add_submodule_import(
|
|
68
|
-
"azure.identity", "DefaultAzureCredential", ImportType.SDKCORE
|
|
69
|
-
)
|
|
61
|
+
imports.add_submodule_import("azure.identity", "DefaultAzureCredential", ImportType.SDKCORE)
|
|
70
62
|
elif isinstance(credential_type, KeyCredentialType):
|
|
71
63
|
imports.add_import("os", ImportType.STDLIB)
|
|
72
64
|
imports.add_submodule_import(
|
|
@@ -75,11 +67,7 @@ class SampleSerializer(BaseSerializer):
|
|
|
75
67
|
ImportType.SDKCORE,
|
|
76
68
|
)
|
|
77
69
|
for param in self.operation.parameters.positional:
|
|
78
|
-
if
|
|
79
|
-
not param.client_default_value
|
|
80
|
-
and not param.optional
|
|
81
|
-
and param.client_name in self.sample_params
|
|
82
|
-
):
|
|
70
|
+
if not param.client_default_value and not param.optional and param.client_name in self.sample_params:
|
|
83
71
|
imports.merge(param.type.imports_for_sample())
|
|
84
72
|
return FileImportSerializer(imports, True)
|
|
85
73
|
|
|
@@ -90,14 +78,10 @@ class SampleSerializer(BaseSerializer):
|
|
|
90
78
|
if isinstance(credential_type, TokenCredentialType):
|
|
91
79
|
special_param.update({"credential": "DefaultAzureCredential()"})
|
|
92
80
|
elif isinstance(credential_type, KeyCredentialType):
|
|
93
|
-
special_param.update(
|
|
94
|
-
{"credential": 'AzureKeyCredential(key=os.getenv("AZURE_KEY"))'}
|
|
95
|
-
)
|
|
81
|
+
special_param.update({"credential": 'AzureKeyCredential(key=os.getenv("AZURE_KEY"))'})
|
|
96
82
|
|
|
97
83
|
params_positional = [
|
|
98
|
-
p
|
|
99
|
-
for p in self.code_model.clients[0].parameters.positional
|
|
100
|
-
if not (p.optional or p.client_default_value)
|
|
84
|
+
p for p in self.code_model.clients[0].parameters.positional if not (p.optional or p.client_default_value)
|
|
101
85
|
]
|
|
102
86
|
client_params = {
|
|
103
87
|
p.client_name: special_param.get(
|
|
@@ -119,11 +103,7 @@ class SampleSerializer(BaseSerializer):
|
|
|
119
103
|
|
|
120
104
|
# prepare operation parameters
|
|
121
105
|
def _operation_params(self) -> Dict[str, Any]:
|
|
122
|
-
params_positional = [
|
|
123
|
-
p
|
|
124
|
-
for p in self.operation.parameters.positional
|
|
125
|
-
if not p.client_default_value
|
|
126
|
-
]
|
|
106
|
+
params_positional = [p for p in self.operation.parameters.positional if not p.client_default_value]
|
|
127
107
|
failure_info = "fail to find required param named {}"
|
|
128
108
|
operation_params = {}
|
|
129
109
|
for param in params_positional:
|
|
@@ -131,12 +111,8 @@ class SampleSerializer(BaseSerializer):
|
|
|
131
111
|
param_value = self.sample_params.get(name)
|
|
132
112
|
if not param.optional:
|
|
133
113
|
if not param_value:
|
|
134
|
-
raise Exception( # pylint: disable=broad-exception-raised
|
|
135
|
-
|
|
136
|
-
)
|
|
137
|
-
operation_params[param.client_name] = self.handle_param(
|
|
138
|
-
param, param_value
|
|
139
|
-
)
|
|
114
|
+
raise Exception(failure_info.format(name)) # pylint: disable=broad-exception-raised
|
|
115
|
+
operation_params[param.client_name] = self.handle_param(param, param_value)
|
|
140
116
|
return operation_params
|
|
141
117
|
|
|
142
118
|
def _operation_group_name(self) -> str:
|
|
@@ -145,9 +121,7 @@ class SampleSerializer(BaseSerializer):
|
|
|
145
121
|
return f".{self.operation_group.property_name}"
|
|
146
122
|
|
|
147
123
|
def _operation_result(self) -> Tuple[str, str]:
|
|
148
|
-
is_response_none = "None" in self.operation.response_type_annotation(
|
|
149
|
-
async_mode=False
|
|
150
|
-
)
|
|
124
|
+
is_response_none = "None" in self.operation.response_type_annotation(async_mode=False)
|
|
151
125
|
lro = ".result()"
|
|
152
126
|
if is_response_none:
|
|
153
127
|
paging, normal_print, return_var = "", "", ""
|
|
@@ -119,9 +119,7 @@ class Test(TestName):
|
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
class TestGeneralSerializer(BaseSerializer):
|
|
122
|
-
def __init__(
|
|
123
|
-
self, code_model: CodeModel, env: Environment, *, is_async: bool = False
|
|
124
|
-
) -> None:
|
|
122
|
+
def __init__(self, code_model: CodeModel, env: Environment, *, is_async: bool = False) -> None:
|
|
125
123
|
super().__init__(code_model, env)
|
|
126
124
|
self.is_async = is_async
|
|
127
125
|
|
|
@@ -131,29 +129,19 @@ class TestGeneralSerializer(BaseSerializer):
|
|
|
131
129
|
|
|
132
130
|
@property
|
|
133
131
|
def test_names(self) -> List[TestName]:
|
|
134
|
-
return [
|
|
135
|
-
TestName(c.name, is_async=self.is_async) for c in self.code_model.clients
|
|
136
|
-
]
|
|
132
|
+
return [TestName(c.name, is_async=self.is_async) for c in self.code_model.clients]
|
|
137
133
|
|
|
138
134
|
@property
|
|
139
135
|
def import_clients(self) -> FileImportSerializer:
|
|
140
136
|
imports = self.init_file_import()
|
|
141
|
-
namespace = get_namespace_from_package_name(
|
|
142
|
-
self.code_model.options["package_name"]
|
|
143
|
-
)
|
|
137
|
+
namespace = get_namespace_from_package_name(self.code_model.options["package_name"])
|
|
144
138
|
|
|
145
|
-
imports.add_submodule_import(
|
|
146
|
-
"devtools_testutils", "AzureRecordedTestCase", ImportType.STDLIB
|
|
147
|
-
)
|
|
139
|
+
imports.add_submodule_import("devtools_testutils", "AzureRecordedTestCase", ImportType.STDLIB)
|
|
148
140
|
if not self.is_async:
|
|
149
141
|
imports.add_import("functools", ImportType.STDLIB)
|
|
150
|
-
imports.add_submodule_import(
|
|
151
|
-
"devtools_testutils", "PowerShellPreparer", ImportType.STDLIB
|
|
152
|
-
)
|
|
142
|
+
imports.add_submodule_import("devtools_testutils", "PowerShellPreparer", ImportType.STDLIB)
|
|
153
143
|
for client in self.code_model.clients:
|
|
154
|
-
imports.add_submodule_import(
|
|
155
|
-
namespace + self.aio_str, client.name, ImportType.STDLIB
|
|
156
|
-
)
|
|
144
|
+
imports.add_submodule_import(namespace + self.aio_str, client.name, ImportType.STDLIB)
|
|
157
145
|
return FileImportSerializer(imports, self.is_async)
|
|
158
146
|
|
|
159
147
|
def serialize_conftest(self) -> str:
|
|
@@ -194,9 +182,7 @@ class TestSerializer(TestGeneralSerializer):
|
|
|
194
182
|
test_name.base_test_class_name,
|
|
195
183
|
ImportType.LOCAL,
|
|
196
184
|
)
|
|
197
|
-
imports.add_submodule_import(
|
|
198
|
-
"testpreparer", test_name.preparer_name, ImportType.LOCAL
|
|
199
|
-
)
|
|
185
|
+
imports.add_submodule_import("testpreparer", test_name.preparer_name, ImportType.LOCAL)
|
|
200
186
|
imports.add_submodule_import(
|
|
201
187
|
"devtools_testutils" + self.aio_str,
|
|
202
188
|
"recorded_by_proxy" + async_suffix,
|
|
@@ -235,9 +221,7 @@ class TestSerializer(TestGeneralSerializer):
|
|
|
235
221
|
for param in required_params:
|
|
236
222
|
model_type = self.get_model_type(param.type)
|
|
237
223
|
param_type = self.get_sub_type(model_type) if model_type else param.type
|
|
238
|
-
operation_params[param.client_name] = json_dumps_template(
|
|
239
|
-
param_type.get_json_template_representation()
|
|
240
|
-
)
|
|
224
|
+
operation_params[param.client_name] = json_dumps_template(param_type.get_json_template_representation())
|
|
241
225
|
return operation_params
|
|
242
226
|
|
|
243
227
|
def get_test(self) -> Test:
|
|
@@ -255,9 +239,7 @@ class TestSerializer(TestGeneralSerializer):
|
|
|
255
239
|
)
|
|
256
240
|
testcases.append(testcase)
|
|
257
241
|
if not testcases:
|
|
258
|
-
raise Exception( # pylint: disable=broad-exception-raised
|
|
259
|
-
"no public operation to test"
|
|
260
|
-
)
|
|
242
|
+
raise Exception("no public operation to test") # pylint: disable=broad-exception-raised
|
|
261
243
|
|
|
262
244
|
return Test(
|
|
263
245
|
client_name=self.client.name,
|
|
@@ -270,9 +252,7 @@ class TestSerializer(TestGeneralSerializer):
|
|
|
270
252
|
@property
|
|
271
253
|
def test_class_name(self) -> str:
|
|
272
254
|
test_name = TestName(self.client.name, is_async=self.is_async)
|
|
273
|
-
class_name =
|
|
274
|
-
"" if self.operation_group.is_mixin else self.operation_group.class_name
|
|
275
|
-
)
|
|
255
|
+
class_name = "" if self.operation_group.is_mixin else self.operation_group.class_name
|
|
276
256
|
return f"Test{test_name.prefix}{class_name}{test_name.async_suffix_capt}"
|
|
277
257
|
|
|
278
258
|
def serialize_test(self) -> str:
|
|
@@ -18,9 +18,7 @@ class TypesSerializer(BaseSerializer):
|
|
|
18
18
|
ImportType.STDLIB,
|
|
19
19
|
)
|
|
20
20
|
for nu in self.code_model.named_unions:
|
|
21
|
-
file_import.merge(
|
|
22
|
-
nu.imports(relative_path=".", model_typing=True, is_types_file=True)
|
|
23
|
-
)
|
|
21
|
+
file_import.merge(nu.imports(relative_path=".", model_typing=True, is_types_file=True))
|
|
24
22
|
return file_import
|
|
25
23
|
|
|
26
24
|
def serialize(self) -> str:
|
|
@@ -114,9 +114,7 @@ class AutorestAPI(ABC):
|
|
|
114
114
|
def message(self, channel: Channel, text: str) -> None:
|
|
115
115
|
"""Send a log message to autorest."""
|
|
116
116
|
|
|
117
|
-
def get_boolean_value(
|
|
118
|
-
self, key: str, default: Optional[bool] = None
|
|
119
|
-
) -> Optional[bool]:
|
|
117
|
+
def get_boolean_value(self, key: str, default: Optional[bool] = None) -> Optional[bool]:
|
|
120
118
|
"""Check if value is present on the line, and interpret it as bool if it was.
|
|
121
119
|
|
|
122
120
|
If value is not not on the line, return the "default".
|
|
@@ -80,15 +80,11 @@ def Process(plugin_name: str, session_id: str) -> bool:
|
|
|
80
80
|
def main() -> None:
|
|
81
81
|
# If --python.debugger is specified on the command line, we call the server.py file internally
|
|
82
82
|
# with flag --debug.
|
|
83
|
-
if "--debug" in sys.argv or os.environ.get(
|
|
84
|
-
"AUTOREST_PYTHON_ATTACH_VSCODE_DEBUG", False
|
|
85
|
-
):
|
|
83
|
+
if "--debug" in sys.argv or os.environ.get("AUTOREST_PYTHON_ATTACH_VSCODE_DEBUG", False):
|
|
86
84
|
try:
|
|
87
85
|
import debugpy # pylint: disable=import-outside-toplevel
|
|
88
86
|
except ImportError as exc:
|
|
89
|
-
raise SystemExit(
|
|
90
|
-
"Please pip install ptvsd in order to use VSCode debugging"
|
|
91
|
-
) from exc
|
|
87
|
+
raise SystemExit("Please pip install ptvsd in order to use VSCode debugging") from exc
|
|
92
88
|
|
|
93
89
|
# 5678 is the default attach port in the VS Code debug configurations
|
|
94
90
|
debugpy.listen(("localhost", 5678))
|
|
@@ -101,9 +97,7 @@ def main() -> None:
|
|
|
101
97
|
_LOGGER.debug("Trying to read")
|
|
102
98
|
message = read_message()
|
|
103
99
|
|
|
104
|
-
response = typing.cast(
|
|
105
|
-
JSONRPC20Response, JSONRPCResponseManager.handle(message, dispatcher)
|
|
106
|
-
).json
|
|
100
|
+
response = typing.cast(JSONRPC20Response, JSONRPCResponseManager.handle(message, dispatcher)).json
|
|
107
101
|
_LOGGER.debug("Produced: %s", response)
|
|
108
102
|
write_message(response)
|
|
109
103
|
_LOGGER.debug("Message processed")
|
|
@@ -72,25 +72,19 @@ class StdStreamAutorestAPI(AutorestAPI):
|
|
|
72
72
|
def read_file(self, filename: Union[str, Path]) -> str:
|
|
73
73
|
_LOGGER.debug("Asking content for file %s", filename)
|
|
74
74
|
filename = os.fspath(filename)
|
|
75
|
-
request = JSONRPC20Request(
|
|
76
|
-
method="ReadFile", params=[self.session_id, filename], _id=42
|
|
77
|
-
)
|
|
75
|
+
request = JSONRPC20Request(method="ReadFile", params=[self.session_id, filename], _id=42)
|
|
78
76
|
write_message(request.json)
|
|
79
77
|
return json.loads(read_message())["result"]
|
|
80
78
|
|
|
81
79
|
def list_inputs(self) -> List[str]:
|
|
82
80
|
_LOGGER.debug("Calling list inputs to Autorest")
|
|
83
|
-
request = JSONRPC20Request(
|
|
84
|
-
method="ListInputs", params=[self.session_id, None], _id=42
|
|
85
|
-
)
|
|
81
|
+
request = JSONRPC20Request(method="ListInputs", params=[self.session_id, None], _id=42)
|
|
86
82
|
write_message(request.json)
|
|
87
83
|
return json.loads(read_message())["result"]
|
|
88
84
|
|
|
89
85
|
def get_value(self, key: str) -> Any:
|
|
90
86
|
_LOGGER.debug("Calling get value to Autorest: %s", key)
|
|
91
|
-
request = JSONRPC20Request(
|
|
92
|
-
method="GetValue", params=[self.session_id, key], _id=42
|
|
93
|
-
)
|
|
87
|
+
request = JSONRPC20Request(method="GetValue", params=[self.session_id, key], _id=42)
|
|
94
88
|
write_message(request.json)
|
|
95
89
|
return json.loads(read_message())["result"]
|
|
96
90
|
|
|
@@ -101,7 +95,5 @@ class StdStreamAutorestAPI(AutorestAPI):
|
|
|
101
95
|
"Channel": channel.value,
|
|
102
96
|
"Text": text,
|
|
103
97
|
}
|
|
104
|
-
request = JSONRPC20Request(
|
|
105
|
-
method="Message", params=[self.session_id, message], is_notification=True
|
|
106
|
-
)
|
|
98
|
+
request = JSONRPC20Request(method="Message", params=[self.session_id, message], is_notification=True)
|
|
107
99
|
write_message(request.json)
|
package/autorest/m2r/__init__.py
CHANGED
|
@@ -34,9 +34,7 @@ class M2R(YamlUpdatePlugin): # pylint: disable=abstract-method
|
|
|
34
34
|
"""Convert in place the YAML str."""
|
|
35
35
|
self._convert_docstring_no_cycles(yaml_data, set())
|
|
36
36
|
|
|
37
|
-
def _convert_docstring_no_cycles(
|
|
38
|
-
self, yaml_data: Union[Dict[str, Any], str], node_list: Set[int]
|
|
39
|
-
) -> None:
|
|
37
|
+
def _convert_docstring_no_cycles(self, yaml_data: Union[Dict[str, Any], str], node_list: Set[int]) -> None:
|
|
40
38
|
"""Walk the YAML tree to convert MD to RST."""
|
|
41
39
|
if id(yaml_data) in node_list:
|
|
42
40
|
return
|
|
@@ -69,6 +67,4 @@ class M2RAutorest(YamlUpdatePluginAutorest, M2R):
|
|
|
69
67
|
if __name__ == "__main__":
|
|
70
68
|
# CADL pipeline will call this
|
|
71
69
|
args, unknown_args = parse_args()
|
|
72
|
-
M2R(
|
|
73
|
-
output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args
|
|
74
|
-
).process()
|
|
70
|
+
M2R(output_folder=args.output_folder, cadl_file=args.cadl_file, **unknown_args).process()
|