@autorest/python 6.7.1 → 6.7.3
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/black/__init__.py +3 -0
- package/autorest/codegen/models/client.py +10 -1
- package/autorest/codegen/models/code_model.py +1 -1
- package/autorest/codegen/models/operation.py +3 -1
- package/autorest/codegen/models/operation_group.py +5 -1
- package/autorest/codegen/models/paging_operation.py +1 -1
- package/autorest/codegen/models/primitive_types.py +1 -0
- package/autorest/codegen/models/request_builder.py +7 -0
- package/autorest/codegen/models/utils.py +2 -0
- package/autorest/codegen/serializers/client_serializer.py +1 -1
- package/autorest/codegen/serializers/sample_serializer.py +3 -1
- package/autorest/codegen/templates/config.py.jinja2 +3 -1
- package/autorest/codegen/templates/operation_group.py.jinja2 +7 -2
- package/autorest/codegen/templates/serialization.py.jinja2 +2 -0
- package/autorest/codegen/templates/vendor.py.jinja2 +4 -2
- package/autorest/multiapi/__init__.py +0 -5
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ from typing import Any, Dict, TYPE_CHECKING, TypeVar, Generic, Union, List, Opti
|
|
|
8
8
|
from .base import BaseModel
|
|
9
9
|
from .parameter_list import ClientGlobalParameterList, ConfigGlobalParameterList
|
|
10
10
|
from .imports import FileImport, ImportType, TypingSection, MsrestImportType
|
|
11
|
-
from .utils import add_to_pylint_disable
|
|
11
|
+
from .utils import add_to_pylint_disable, NAME_LENGTH_LIMIT
|
|
12
12
|
from .operation_group import OperationGroup
|
|
13
13
|
from .request_builder import (
|
|
14
14
|
RequestBuilder,
|
|
@@ -148,6 +148,8 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]):
|
|
|
148
148
|
retval = add_to_pylint_disable("", "client-accepts-api-version-keyword")
|
|
149
149
|
if len(self.operation_groups) > 6:
|
|
150
150
|
retval = add_to_pylint_disable(retval, "too-many-instance-attributes")
|
|
151
|
+
if len(self.name) > NAME_LENGTH_LIMIT:
|
|
152
|
+
retval = add_to_pylint_disable(retval, "name-too-long")
|
|
151
153
|
return retval
|
|
152
154
|
|
|
153
155
|
@property
|
|
@@ -371,6 +373,13 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]):
|
|
|
371
373
|
class Config(_ClientConfigBase[ConfigGlobalParameterList]):
|
|
372
374
|
"""Model representing our Config type."""
|
|
373
375
|
|
|
376
|
+
@property
|
|
377
|
+
def pylint_disable(self) -> str:
|
|
378
|
+
retval = add_to_pylint_disable("", "too-many-instance-attributes")
|
|
379
|
+
if len(self.name) + len("Configuration") > NAME_LENGTH_LIMIT:
|
|
380
|
+
retval = add_to_pylint_disable(retval, "name-too-long")
|
|
381
|
+
return retval
|
|
382
|
+
|
|
374
383
|
@property
|
|
375
384
|
def description(self) -> str:
|
|
376
385
|
return (
|
|
@@ -133,7 +133,7 @@ class CodeModel: # pylint: disable=too-many-public-methods, disable=too-many-in
|
|
|
133
133
|
return True
|
|
134
134
|
if async_mode:
|
|
135
135
|
return self.need_mixin_abc
|
|
136
|
-
return self.need_request_converter or self.need_mixin_abc
|
|
136
|
+
return self.need_request_converter or self.need_mixin_abc or self.has_etag
|
|
137
137
|
|
|
138
138
|
@property
|
|
139
139
|
def need_request_converter(self) -> bool:
|
|
@@ -18,7 +18,7 @@ from typing import (
|
|
|
18
18
|
|
|
19
19
|
from .request_builder_parameter import RequestBuilderParameter
|
|
20
20
|
|
|
21
|
-
from .utils import OrderedSet, add_to_pylint_disable
|
|
21
|
+
from .utils import OrderedSet, add_to_pylint_disable, NAME_LENGTH_LIMIT
|
|
22
22
|
from .base_builder import BaseBuilder
|
|
23
23
|
from .imports import FileImport, ImportType, TypingSection
|
|
24
24
|
from .response import (
|
|
@@ -143,6 +143,8 @@ class OperationBase( # pylint: disable=too-many-public-methods
|
|
|
143
143
|
retval = add_to_pylint_disable(retval, "protected-access")
|
|
144
144
|
except ValueError:
|
|
145
145
|
pass
|
|
146
|
+
if len(self.name) > NAME_LENGTH_LIMIT:
|
|
147
|
+
retval = add_to_pylint_disable(retval, "name-too-long")
|
|
146
148
|
return retval
|
|
147
149
|
|
|
148
150
|
def cls_type_annotation(self, *, async_mode: bool) -> str:
|
|
@@ -10,7 +10,7 @@ from autorest.codegen.models.utils import OrderedSet
|
|
|
10
10
|
from .base import BaseModel
|
|
11
11
|
from .operation import get_operation
|
|
12
12
|
from .imports import FileImport, ImportType, TypingSection
|
|
13
|
-
from .utils import add_to_pylint_disable
|
|
13
|
+
from .utils import add_to_pylint_disable, NAME_LENGTH_LIMIT
|
|
14
14
|
|
|
15
15
|
if TYPE_CHECKING:
|
|
16
16
|
from .code_model import CodeModel
|
|
@@ -67,6 +67,10 @@ class OperationGroup(BaseModel):
|
|
|
67
67
|
retval: str = ""
|
|
68
68
|
if self.has_abstract_operations:
|
|
69
69
|
retval = add_to_pylint_disable(retval, "abstract-class-instantiated")
|
|
70
|
+
if len(self.operations) > 20:
|
|
71
|
+
retval = add_to_pylint_disable(retval, "too-many-public-methods")
|
|
72
|
+
if len(self.class_name) > NAME_LENGTH_LIMIT:
|
|
73
|
+
retval = add_to_pylint_disable(retval, "name-too-long")
|
|
70
74
|
return retval
|
|
71
75
|
|
|
72
76
|
@property
|
|
@@ -80,7 +80,7 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
80
80
|
|
|
81
81
|
@property
|
|
82
82
|
def continuation_token_name(self) -> Optional[str]:
|
|
83
|
-
wire_name = self.yaml_data
|
|
83
|
+
wire_name = self.yaml_data.get("continuationTokenName")
|
|
84
84
|
if not wire_name:
|
|
85
85
|
# That's an ok scenario, it just means no next page possible
|
|
86
86
|
return None
|
|
@@ -16,6 +16,7 @@ from typing import (
|
|
|
16
16
|
from abc import abstractmethod
|
|
17
17
|
|
|
18
18
|
from .base_builder import BaseBuilder
|
|
19
|
+
from .utils import add_to_pylint_disable, NAME_LENGTH_LIMIT
|
|
19
20
|
from .parameter_list import (
|
|
20
21
|
RequestBuilderParameterList,
|
|
21
22
|
OverloadedRequestBuilderParameterList,
|
|
@@ -56,6 +57,12 @@ class RequestBuilderBase(BaseBuilder[ParameterListType]):
|
|
|
56
57
|
self.method: str = yaml_data["method"]
|
|
57
58
|
self.want_tracing = False
|
|
58
59
|
|
|
60
|
+
@property
|
|
61
|
+
def pylint_disable(self) -> str:
|
|
62
|
+
if len(self.name) > NAME_LENGTH_LIMIT:
|
|
63
|
+
return add_to_pylint_disable("", "name-too-long")
|
|
64
|
+
return ""
|
|
65
|
+
|
|
59
66
|
def response_type_annotation(self, **kwargs) -> str:
|
|
60
67
|
return "HttpRequest"
|
|
61
68
|
|
|
@@ -164,7 +164,7 @@ class ClientSerializer:
|
|
|
164
164
|
api_version = ""
|
|
165
165
|
retval.extend(
|
|
166
166
|
[
|
|
167
|
-
f"self.{og.property_name} = {og.class_name}(
|
|
167
|
+
f"self.{og.property_name} = {og.class_name}(",
|
|
168
168
|
f" self._client, self._config, self._serialize, self._deserialize{api_version}",
|
|
169
169
|
")",
|
|
170
170
|
]
|
|
@@ -125,7 +125,9 @@ class SampleSerializer:
|
|
|
125
125
|
param_value = self.sample_params.get(name)
|
|
126
126
|
if not param.optional:
|
|
127
127
|
if not param_value:
|
|
128
|
-
raise Exception(
|
|
128
|
+
raise Exception( # pylint: disable=broad-exception-raised
|
|
129
|
+
failure_info.format(name)
|
|
130
|
+
)
|
|
129
131
|
operation_params[param.client_name] = self.handle_param(
|
|
130
132
|
param, param_value
|
|
131
133
|
)
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
class {{ client.name }}Configuration(
|
|
1
|
+
class {{ client.name }}Configuration( {{ client.config.pylint_disable }}
|
|
2
|
+
Configuration
|
|
3
|
+
):
|
|
2
4
|
"""Configuration for {{ client.name }}.
|
|
3
5
|
|
|
4
6
|
Note that all parameters used to create this instance are saved as instance
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
{% set disable = " # pylint: disable=too-many-public-methods" if operation_group.operations | length > 20 else "" %}
|
|
2
1
|
{% set base_class = ("(" + operation_group.base_class + ")") if operation_group.base_class else "" %}
|
|
3
2
|
{% macro check_abstract_methods() %}
|
|
4
3
|
{% if operation_group.has_abstract_operations %}
|
|
@@ -9,7 +8,13 @@
|
|
|
9
8
|
])
|
|
10
9
|
{% endif %}
|
|
11
10
|
{% endmacro %}
|
|
12
|
-
|
|
11
|
+
{% if operation_group.base_class %}
|
|
12
|
+
class {{ operation_group.class_name }}( {{ operation_group.pylint_disable }}
|
|
13
|
+
{{ operation_group.base_class }}
|
|
14
|
+
):
|
|
15
|
+
{% else %}
|
|
16
|
+
class {{ operation_group.class_name }}: {{ operation_group.pylint_disable }}
|
|
17
|
+
{% endif %}
|
|
13
18
|
{% if not operation_group.is_mixin %}
|
|
14
19
|
"""
|
|
15
20
|
.. warning::
|
|
@@ -732,6 +732,8 @@ class Serializer(object):
|
|
|
732
732
|
|
|
733
733
|
if kwargs.get("skip_quote") is True:
|
|
734
734
|
output = str(output)
|
|
735
|
+
# https://github.com/Azure/autorest.python/issues/2063
|
|
736
|
+
output = output.replace("{", quote("{")).replace("}", quote("}"))
|
|
735
737
|
else:
|
|
736
738
|
output = quote(str(output), safe="")
|
|
737
739
|
except SerializationError:
|
|
@@ -13,8 +13,10 @@ def _convert_request(request, files=None):
|
|
|
13
13
|
{% endif %}
|
|
14
14
|
{% if code_model.need_mixin_abc %}
|
|
15
15
|
{% for client in clients | selectattr("has_mixin") %}
|
|
16
|
-
|
|
17
|
-
class {{ client.name }}MixinABC(
|
|
16
|
+
{% set pylint_disable = "# pylint: disable=name-too-long" if (client.name | length) + ("MixinABC" | length) > 40 else "" %}
|
|
17
|
+
class {{ client.name }}MixinABC( {{ pylint_disable }}
|
|
18
|
+
ABC
|
|
19
|
+
):
|
|
18
20
|
"""DO NOT use this class. It is for internal typing use only."""
|
|
19
21
|
_client: "{{ keywords.async_class }}PipelineClient"
|
|
20
22
|
_config: {{ client.name }}Configuration
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import sys
|
|
7
7
|
import logging
|
|
8
8
|
import json
|
|
9
|
-
import shutil
|
|
10
9
|
|
|
11
10
|
from collections import defaultdict
|
|
12
11
|
from pathlib import Path
|
|
@@ -174,10 +173,6 @@ class MultiAPI(ReaderAndWriter): # pylint: disable=abstract-method
|
|
|
174
173
|
user_specified_default_api=self.user_specified_default_api,
|
|
175
174
|
)
|
|
176
175
|
|
|
177
|
-
# In case we are transitioning from a single api generation, clean old folders
|
|
178
|
-
shutil.rmtree(str(self.output_folder / "operations"), ignore_errors=True)
|
|
179
|
-
shutil.rmtree(str(self.output_folder / "models"), ignore_errors=True)
|
|
180
|
-
|
|
181
176
|
multiapi_serializer = self.serializer
|
|
182
177
|
multiapi_serializer.serialize(code_model, self.no_async)
|
|
183
178
|
|