@autorest/python 6.4.7 → 6.4.8
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/codegen/__init__.py +8 -2
- package/autorest/codegen/models/client.py +2 -0
- package/autorest/codegen/models/operation.py +2 -0
- package/autorest/codegen/models/request_builder.py +7 -0
- package/autorest/codegen/serializers/builder_serializer.py +11 -1
- package/autorest/codegen/templates/packaging_templates/setup.py.jinja2 +3 -3
- package/package.json +1 -1
|
@@ -16,6 +16,10 @@ from .serializers import JinjaSerializer, JinjaSerializerAutorest
|
|
|
16
16
|
from ._utils import DEFAULT_HEADER_TEXT
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
def _default_pprint(package_name: str) -> str:
|
|
20
|
+
return " ".join([i.capitalize() for i in package_name.split("-")])
|
|
21
|
+
|
|
22
|
+
|
|
19
23
|
def _validate_code_model_options(options: Dict[str, Any]) -> None:
|
|
20
24
|
if options["builders_visibility"] not in ["public", "hidden", "embedded"]:
|
|
21
25
|
raise ValueError(
|
|
@@ -126,6 +130,7 @@ class CodeGenerator(Plugin):
|
|
|
126
130
|
if self.options.get("cadl_file") is not None:
|
|
127
131
|
models_mode_default = "dpg"
|
|
128
132
|
|
|
133
|
+
package_name = self.options.get("package-name")
|
|
129
134
|
options: Dict[str, Any] = {
|
|
130
135
|
"azure_arm": azure_arm,
|
|
131
136
|
"head_as_boolean": self.options.get("head-as-boolean", True),
|
|
@@ -134,7 +139,7 @@ class CodeGenerator(Plugin):
|
|
|
134
139
|
"no_async": self.options.get("no-async", False),
|
|
135
140
|
"no_namespace_folders": self.options.get("no-namespace-folders", False),
|
|
136
141
|
"basic_setup_py": self.options.get("basic-setup-py", False),
|
|
137
|
-
"package_name":
|
|
142
|
+
"package_name": package_name,
|
|
138
143
|
"package_version": self.options.get("package-version"),
|
|
139
144
|
"client_side_validation": self.options.get("client-side-validation", False),
|
|
140
145
|
"tracing": self.options.get("tracing", show_operations),
|
|
@@ -156,7 +161,8 @@ class CodeGenerator(Plugin):
|
|
|
156
161
|
"combine-operation-files", version_tolerant
|
|
157
162
|
),
|
|
158
163
|
"package_mode": self.options.get("package-mode"),
|
|
159
|
-
"package_pprint_name": self.options.get("package-pprint-name")
|
|
164
|
+
"package_pprint_name": self.options.get("package-pprint-name")
|
|
165
|
+
or _default_pprint(str(package_name)),
|
|
160
166
|
"package_configuration": self.options.get("package-configuration"),
|
|
161
167
|
"default_optional_constants_to_none": self.options.get(
|
|
162
168
|
"default-optional-constants-to-none",
|
|
@@ -146,6 +146,8 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]):
|
|
|
146
146
|
retval = add_to_pylint_disable("", "client-accepts-api-version-keyword")
|
|
147
147
|
if len(self.operation_groups) > 6:
|
|
148
148
|
retval = add_to_pylint_disable(retval, "too-many-instance-attributes")
|
|
149
|
+
if len(self.name) > 40:
|
|
150
|
+
retval = add_to_pylint_disable(retval, "name-too-long")
|
|
149
151
|
return retval
|
|
150
152
|
|
|
151
153
|
@property
|
|
@@ -130,6 +130,8 @@ class OperationBase( # pylint: disable=too-many-public-methods
|
|
|
130
130
|
if self.response_type_annotation(async_mode=False) == "None":
|
|
131
131
|
# doesn't matter if it's async or not
|
|
132
132
|
retval = add_to_pylint_disable(retval, "inconsistent-return-statements")
|
|
133
|
+
if len(self.name) > 40:
|
|
134
|
+
retval = add_to_pylint_disable(retval, "name-too-long")
|
|
133
135
|
return retval
|
|
134
136
|
|
|
135
137
|
def cls_type_annotation(self, *, async_mode: bool) -> str:
|
|
@@ -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
|
|
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) > 40:
|
|
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
|
|
|
@@ -58,6 +58,14 @@ OperationType = TypeVar(
|
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
def _xml_config(send_xml: bool, content_types: List[str]) -> str:
|
|
62
|
+
if not (send_xml and "xml" in str(content_types)):
|
|
63
|
+
return ""
|
|
64
|
+
if len(content_types) == 1:
|
|
65
|
+
return ", is_xml=True"
|
|
66
|
+
return ", is_xml='xml' in str(content_type)"
|
|
67
|
+
|
|
68
|
+
|
|
61
69
|
def _escape_str(input_str: str) -> str:
|
|
62
70
|
replace = input_str.replace("'", "\\'")
|
|
63
71
|
return f'"{replace}"'
|
|
@@ -741,7 +749,9 @@ class _OperationSerializer(
|
|
|
741
749
|
if xml_serialization_ctxt and self.code_model.options["models_mode"]:
|
|
742
750
|
retval.append(f'{ser_ctxt_name} = {{"xml": {{{xml_serialization_ctxt}}}}}')
|
|
743
751
|
if self.code_model.options["models_mode"] == "msrest":
|
|
744
|
-
is_xml_cmd =
|
|
752
|
+
is_xml_cmd = _xml_config(
|
|
753
|
+
send_xml, builder.parameters.body_parameter.content_types
|
|
754
|
+
)
|
|
745
755
|
serialization_ctxt_cmd = (
|
|
746
756
|
f", {ser_ctxt_name}={ser_ctxt_name}" if xml_serialization_ctxt else ""
|
|
747
757
|
)
|
|
@@ -24,12 +24,12 @@ with open(os.path.join(package_folder_path, "_version.py"), "r") as fd:
|
|
|
24
24
|
|
|
25
25
|
if not version:
|
|
26
26
|
raise RuntimeError("Cannot find version information")
|
|
27
|
-
{% set description = "Microsoft
|
|
27
|
+
{% set description = "\"Microsoft {} Client Library for Python\".format(PACKAGE_PPRINT_NAME)" %}
|
|
28
28
|
{% set author_email = "azpysdkhelp@microsoft.com" %}
|
|
29
29
|
{% set url = "https://github.com/Azure/azure-sdk-for-python/tree/main/sdk" %}
|
|
30
30
|
{% else %}
|
|
31
31
|
version = "{{ package_version }}"
|
|
32
|
-
{% set description = "%s"|format(package_name) %}
|
|
32
|
+
{% set description = "\"%s\""|format(package_name) %}
|
|
33
33
|
{% set long_description = code_model.description %}
|
|
34
34
|
{% set author_email = "" %}
|
|
35
35
|
{% set url = "" %}
|
|
@@ -38,7 +38,7 @@ version = "{{ package_version }}"
|
|
|
38
38
|
setup(
|
|
39
39
|
name=PACKAGE_NAME,
|
|
40
40
|
version=version,
|
|
41
|
-
description=
|
|
41
|
+
description={{ description }},
|
|
42
42
|
{% if package_mode %}
|
|
43
43
|
long_description=open("README.md", "r").read(),
|
|
44
44
|
long_description_content_type="text/markdown",
|