@autorest/python 5.15.0 → 5.18.0
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/ChangeLog.md +98 -4
- package/README.md +30 -4
- package/autorest/__init__.py +2 -3
- package/autorest/black/__init__.py +12 -5
- package/autorest/codegen/__init__.py +122 -211
- package/autorest/codegen/models/__init__.py +122 -78
- package/autorest/codegen/models/base_builder.py +70 -72
- package/autorest/codegen/models/base_model.py +7 -5
- package/autorest/codegen/models/{base_schema.py → base_type.py} +68 -45
- package/autorest/codegen/models/client.py +193 -40
- package/autorest/codegen/models/code_model.py +145 -245
- package/autorest/codegen/models/combined_type.py +107 -0
- package/autorest/codegen/models/constant_type.py +122 -0
- package/autorest/codegen/models/credential_types.py +224 -0
- package/autorest/codegen/models/dictionary_type.py +131 -0
- package/autorest/codegen/models/enum_type.py +195 -0
- package/autorest/codegen/models/imports.py +93 -41
- package/autorest/codegen/models/list_type.py +149 -0
- package/autorest/codegen/models/lro_operation.py +90 -133
- package/autorest/codegen/models/lro_paging_operation.py +28 -12
- package/autorest/codegen/models/model_type.py +262 -0
- package/autorest/codegen/models/operation.py +412 -259
- package/autorest/codegen/models/operation_group.py +80 -91
- package/autorest/codegen/models/paging_operation.py +101 -117
- package/autorest/codegen/models/parameter.py +302 -341
- package/autorest/codegen/models/parameter_list.py +373 -357
- package/autorest/codegen/models/primitive_types.py +544 -0
- package/autorest/codegen/models/property.py +136 -134
- package/autorest/codegen/models/request_builder.py +138 -86
- package/autorest/codegen/models/request_builder_parameter.py +122 -86
- package/autorest/codegen/models/response.py +325 -0
- package/autorest/codegen/models/utils.py +13 -17
- package/autorest/codegen/serializers/__init__.py +212 -112
- package/autorest/codegen/serializers/builder_serializer.py +931 -1040
- package/autorest/codegen/serializers/client_serializer.py +140 -84
- package/autorest/codegen/serializers/general_serializer.py +26 -50
- package/autorest/codegen/serializers/import_serializer.py +96 -31
- package/autorest/codegen/serializers/metadata_serializer.py +39 -79
- package/autorest/codegen/serializers/model_base_serializer.py +62 -34
- package/autorest/codegen/serializers/model_generic_serializer.py +9 -10
- package/autorest/codegen/serializers/model_init_serializer.py +4 -2
- package/autorest/codegen/serializers/model_python3_serializer.py +29 -22
- package/autorest/codegen/serializers/operation_groups_serializer.py +21 -19
- package/autorest/codegen/serializers/operations_init_serializer.py +23 -11
- package/autorest/codegen/serializers/parameter_serializer.py +174 -0
- package/autorest/codegen/serializers/patch_serializer.py +4 -1
- package/autorest/codegen/serializers/request_builders_serializer.py +57 -0
- package/autorest/codegen/serializers/utils.py +0 -126
- package/autorest/codegen/templates/MANIFEST.in.jinja2 +1 -0
- package/autorest/codegen/templates/{service_client.py.jinja2 → client.py.jinja2} +7 -7
- package/autorest/codegen/templates/config.py.jinja2 +13 -13
- package/autorest/codegen/templates/enum.py.jinja2 +4 -4
- package/autorest/codegen/templates/enum_container.py.jinja2 +1 -1
- package/autorest/codegen/templates/init.py.jinja2 +3 -3
- package/autorest/codegen/templates/lro_operation.py.jinja2 +6 -5
- package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +6 -5
- package/autorest/codegen/templates/metadata.json.jinja2 +36 -35
- package/autorest/codegen/templates/model.py.jinja2 +23 -24
- package/autorest/codegen/templates/model_container.py.jinja2 +2 -1
- package/autorest/codegen/templates/model_init.py.jinja2 +3 -5
- package/autorest/codegen/templates/operation.py.jinja2 +10 -14
- package/autorest/codegen/templates/operation_group.py.jinja2 +9 -15
- package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -1
- package/autorest/codegen/templates/operation_tools.jinja2 +8 -2
- package/autorest/codegen/templates/paging_operation.py.jinja2 +7 -8
- package/autorest/codegen/templates/request_builder.py.jinja2 +19 -10
- package/autorest/codegen/templates/setup.py.jinja2 +9 -3
- package/autorest/codegen/templates/vendor.py.jinja2 +1 -1
- package/autorest/jsonrpc/__init__.py +7 -12
- package/autorest/jsonrpc/localapi.py +4 -3
- package/autorest/jsonrpc/server.py +28 -9
- package/autorest/jsonrpc/stdstream.py +13 -6
- package/autorest/m2r/__init__.py +5 -8
- package/autorest/m4reformatter/__init__.py +1126 -0
- package/autorest/multiapi/__init__.py +24 -14
- package/autorest/multiapi/models/client.py +21 -11
- package/autorest/multiapi/models/code_model.py +23 -10
- package/autorest/multiapi/models/config.py +4 -1
- package/autorest/multiapi/models/constant_global_parameter.py +1 -0
- package/autorest/multiapi/models/global_parameter.py +2 -1
- package/autorest/multiapi/models/global_parameters.py +14 -8
- package/autorest/multiapi/models/imports.py +24 -17
- package/autorest/multiapi/models/mixin_operation.py +5 -5
- package/autorest/multiapi/models/operation_group.py +2 -1
- package/autorest/multiapi/models/operation_mixin_group.py +21 -10
- package/autorest/multiapi/serializers/__init__.py +20 -25
- package/autorest/multiapi/serializers/import_serializer.py +47 -17
- package/autorest/multiapi/serializers/multiapi_serializer.py +17 -17
- package/autorest/multiapi/templates/multiapi_config.py.jinja2 +3 -3
- package/autorest/multiapi/templates/multiapi_init.py.jinja2 +2 -2
- package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +4 -4
- package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +9 -9
- package/autorest/multiapi/utils.py +3 -3
- package/autorest/postprocess/__init__.py +202 -0
- package/autorest/postprocess/get_all.py +19 -0
- package/autorest/postprocess/venvtools.py +73 -0
- package/autorest/preprocess/__init__.py +210 -0
- package/autorest/preprocess/helpers.py +54 -0
- package/autorest/{namer → preprocess}/python_mappings.py +25 -32
- package/package.json +3 -3
- package/run-python3.js +2 -3
- package/venvtools.py +1 -1
- package/autorest/codegen/models/constant_schema.py +0 -101
- package/autorest/codegen/models/credential_model.py +0 -47
- package/autorest/codegen/models/credential_schema.py +0 -91
- package/autorest/codegen/models/credential_schema_policy.py +0 -77
- package/autorest/codegen/models/dictionary_schema.py +0 -103
- package/autorest/codegen/models/enum_schema.py +0 -215
- package/autorest/codegen/models/list_schema.py +0 -123
- package/autorest/codegen/models/object_schema.py +0 -253
- package/autorest/codegen/models/primitive_schemas.py +0 -466
- package/autorest/codegen/models/request_builder_parameter_list.py +0 -280
- package/autorest/codegen/models/rest.py +0 -42
- package/autorest/codegen/models/schema_request.py +0 -45
- package/autorest/codegen/models/schema_response.py +0 -136
- package/autorest/codegen/serializers/rest_serializer.py +0 -57
- package/autorest/namer/__init__.py +0 -25
- package/autorest/namer/name_converter.py +0 -412
package/ChangeLog.md
CHANGED
|
@@ -1,4 +1,97 @@
|
|
|
1
|
-
# Change
|
|
1
|
+
# Change
|
|
2
|
+
|
|
3
|
+
### 2022-07-09 - 5.18.0
|
|
4
|
+
|
|
5
|
+
| Library | Min Version |
|
|
6
|
+
| ----------------------------------------------------------------------- | ----------- |
|
|
7
|
+
| `@autorest/core` | `3.8.1` |
|
|
8
|
+
| `@autorest/modelerfour` | `4.23.5` |
|
|
9
|
+
| `azure-core` dep of generated code | `1.23.0` |
|
|
10
|
+
| `msrest` dep of generated code | `0.6.21` |
|
|
11
|
+
| `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
|
|
12
|
+
|
|
13
|
+
**Breaking Changes in Version Tolerant**
|
|
14
|
+
|
|
15
|
+
- No longer allow users to specify `api_version` on the method level #1281
|
|
16
|
+
- Make `content_type` param required with no default if streaming with no `application/octet-stream` #1288
|
|
17
|
+
|
|
18
|
+
**Bug Fixes**
|
|
19
|
+
|
|
20
|
+
- Fix duplicate params in signature with `--payload-flattening-threshold` #1289
|
|
21
|
+
- Fix overloaded request builder signatures #1289
|
|
22
|
+
|
|
23
|
+
### 2022-xx-xx - 5.17.1
|
|
24
|
+
|
|
25
|
+
| Library | Min Version |
|
|
26
|
+
| ----------------------------------------------------------------------- | ----------- |
|
|
27
|
+
| `@autorest/core` | `3.8.1` |
|
|
28
|
+
| `@autorest/modelerfour` | `4.23.5` |
|
|
29
|
+
| `azure-core` dep of generated code | `1.23.0` |
|
|
30
|
+
| `msrest` dep of generated code | `0.6.21` |
|
|
31
|
+
| `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
|
|
32
|
+
|
|
33
|
+
**Bug Fixes**
|
|
34
|
+
|
|
35
|
+
- Improve docstring templates, specifically for polymorphic bodies #1279
|
|
36
|
+
|
|
37
|
+
### 2022-06-02 - 5.17.0
|
|
38
|
+
|
|
39
|
+
| Library | Min Version |
|
|
40
|
+
| ----------------------------------------------------------------------- | ----------- |
|
|
41
|
+
| `@autorest/core` | `3.8.1` |
|
|
42
|
+
| `@autorest/modelerfour` | `4.23.5` |
|
|
43
|
+
| `azure-core` dep of generated code | `1.23.0` |
|
|
44
|
+
| `msrest` dep of generated code | `0.6.21` |
|
|
45
|
+
| `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
|
|
46
|
+
|
|
47
|
+
**New Features**
|
|
48
|
+
|
|
49
|
+
- Hide `api_version` in doc string for singleapi SDK even if contains multi api versions #1239
|
|
50
|
+
- Add overloads for operations with different body types. We now sniff bodies and assign content type based off of body type. #1230
|
|
51
|
+
- Add flag `--postprocess`. Run this after doing customizations for full mypy support
|
|
52
|
+
|
|
53
|
+
**Breaking Changes in Version Tolerant**
|
|
54
|
+
|
|
55
|
+
- Have stream responses directly return an iterator of bytes, so you don't need to call `.iter_bytes()` on the response object. #1254
|
|
56
|
+
- If generating with `--models-mode=msrest` in version tolerant, we hide paging models #1259
|
|
57
|
+
|
|
58
|
+
**Breaking Changes in Request Builders**
|
|
59
|
+
|
|
60
|
+
- Request builders for LRO operations have the `_initial` suffix removed from their name #1241
|
|
61
|
+
- Request builders from groups with reserved words will now be padded with the word "Operations" instead of "Builders" #1243
|
|
62
|
+
|
|
63
|
+
**Bug Fixes**
|
|
64
|
+
|
|
65
|
+
- Make sure `any-object` schemas from swagger are typed with `MutableMapping`s #1243
|
|
66
|
+
- Make typing for parameters `Optional` only if `None` is a valid input, not only if it is specified as `optional` in swagger #1244
|
|
67
|
+
- Fix for render failure of `README.md` when `--package-mode==dataplane` #1247
|
|
68
|
+
- Fix typing for stream responses to iterators of bytes. #1254
|
|
69
|
+
- Additional linting support #1265
|
|
70
|
+
- Fix Sphinx documentation for raised exception #1264
|
|
71
|
+
- Use `api_version` in `_config` as default value for operation function #1268
|
|
72
|
+
|
|
73
|
+
**Other Changes**
|
|
74
|
+
|
|
75
|
+
- Update template files for `--package-mode` # 1248
|
|
76
|
+
|
|
77
|
+
### 2022-04-18 - 5.16.0
|
|
78
|
+
|
|
79
|
+
| Library | Min Version |
|
|
80
|
+
| ----------------------------------------------------------------------- | ----------- |
|
|
81
|
+
| `@autorest/core` | `3.6.2` |
|
|
82
|
+
| `@autorest/modelerfour` | `4.19.1` |
|
|
83
|
+
| `azure-core` dep of generated code | `1.23.0` |
|
|
84
|
+
| `msrest` dep of generated code | `0.6.21` |
|
|
85
|
+
| `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
|
|
86
|
+
|
|
87
|
+
**Breaking Changes in Version Tolerant Generation**
|
|
88
|
+
|
|
89
|
+
- We no longer generate operations for operations with multipart or urlencoded bodies. SDK writers must implement these operations in their customized patch file. See https://aka.ms/azsdk/python/dpcodegen/python/customize for how to customize generated code #1223
|
|
90
|
+
|
|
91
|
+
**Bug Fixes**
|
|
92
|
+
|
|
93
|
+
- Drop package dependency on "@azure-tools/extension", switch to "@autorest/system-requirements" #1229
|
|
94
|
+
- Fix `content_type` generation in multiapi SDKs with multiple content types for bodies #1232
|
|
2
95
|
|
|
3
96
|
### 2022-04-07 - 5.15.0
|
|
4
97
|
|
|
@@ -15,6 +108,7 @@
|
|
|
15
108
|
- Add support for security configurations in the swagger. For more information, see https://github.com/Azure/autorest/blob/main/docs/generate/authentication.md #1161
|
|
16
109
|
- Add support for handwritten customizations of generated code. For more information, see https://aka.ms/azsdk/python/dpcodegen/python/customize #1153
|
|
17
110
|
- Allow `header` and `params` as kwargs in operation and request-build function to hand over REST Header and Query parameters case insensitively #1183
|
|
111
|
+
- Typing operation parameters as JSON, Primitives or Any for `--version-tolerant` #1210
|
|
18
112
|
|
|
19
113
|
**Bug Fixes**
|
|
20
114
|
|
|
@@ -25,7 +119,7 @@
|
|
|
25
119
|
|
|
26
120
|
**Breaking Changes in Version Tolerant Generation**
|
|
27
121
|
|
|
28
|
-
- Change client filenames to `_client.py`
|
|
122
|
+
- Change client filenames to `_client.py` #1206
|
|
29
123
|
- Change the models filename from `_models_py3.py` to `_models.py` #1204
|
|
30
124
|
- Change the enums filename to `_enums.py` #1204
|
|
31
125
|
|
|
@@ -696,7 +790,7 @@ Modelerfour version: 4.13.351
|
|
|
696
790
|
**Bug Fixes**
|
|
697
791
|
|
|
698
792
|
- Corrected ordering of summary and description in generated methods #640
|
|
699
|
-
- Have `IOSchema` call super init to get all of the properties shared in `
|
|
793
|
+
- Have `IOSchema` call super init to get all of the properties shared in `BaseType` #642
|
|
700
794
|
|
|
701
795
|
### 2020-05-15 - 5.0.0-preview.7
|
|
702
796
|
|
|
@@ -841,7 +935,7 @@ Modelerfour version: 4.12.276
|
|
|
841
935
|
|
|
842
936
|
- Will no longer permit generated enums and models to have the same name #504
|
|
843
937
|
- No longer exposing models from operation groups without importing them #486
|
|
844
|
-
- Now correctly deserializes error's that have an empty object (
|
|
938
|
+
- Now correctly deserializes error's that have an empty object (AnyType) as a model #516
|
|
845
939
|
- Added a list of parameter names to reserved parameter words, so there won't be clashes #525
|
|
846
940
|
- If a property's schema is readonly, we will show that property as being readonly (taken from m4 update #234)
|
|
847
941
|
- Remove `"azure-"` prefix from user agent name #523
|
package/README.md
CHANGED
|
@@ -30,13 +30,17 @@ modelerfour:
|
|
|
30
30
|
flatten-payloads: true
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
```yaml $(postprocess)
|
|
34
|
+
allow-no-input: true
|
|
35
|
+
```
|
|
36
|
+
|
|
33
37
|
```yaml !$(multiapiscript)
|
|
34
38
|
pass-thru:
|
|
35
39
|
- model-deduplicator
|
|
36
40
|
- subset-reducer
|
|
37
|
-
version: ~3.
|
|
41
|
+
version: ~3.8.1
|
|
38
42
|
use-extension:
|
|
39
|
-
"@autorest/modelerfour": ~4.
|
|
43
|
+
"@autorest/modelerfour": ~4.23.5
|
|
40
44
|
|
|
41
45
|
modelerfour:
|
|
42
46
|
resolve-schema-name-collisons: true
|
|
@@ -69,11 +73,14 @@ pipeline:
|
|
|
69
73
|
python/m2r:
|
|
70
74
|
input: python
|
|
71
75
|
|
|
72
|
-
python/
|
|
76
|
+
python/m4reformatter:
|
|
73
77
|
input: python/m2r
|
|
74
78
|
|
|
79
|
+
python/preprocess:
|
|
80
|
+
input: python/m4reformatter
|
|
81
|
+
|
|
75
82
|
python/codegen:
|
|
76
|
-
input: python/
|
|
83
|
+
input: python/preprocess
|
|
77
84
|
output-artifact: python-files
|
|
78
85
|
|
|
79
86
|
python/codegen/emitter:
|
|
@@ -126,6 +133,25 @@ scope-black/emitter:
|
|
|
126
133
|
output-artifact: python-files
|
|
127
134
|
```
|
|
128
135
|
|
|
136
|
+
# Post-process customized code for mypy pipeline
|
|
137
|
+
|
|
138
|
+
```yaml $(postprocess)
|
|
139
|
+
pipeline:
|
|
140
|
+
python/postprocess:
|
|
141
|
+
scope: postprocess
|
|
142
|
+
output-artifact: python-files
|
|
143
|
+
|
|
144
|
+
python/postprocess/emitter:
|
|
145
|
+
input: postprocess
|
|
146
|
+
scope: scope-postprocess/emitter
|
|
147
|
+
|
|
148
|
+
scope-postprocess/emitter:
|
|
149
|
+
input-artifact: python-files
|
|
150
|
+
output-uri-expr: $key
|
|
151
|
+
|
|
152
|
+
output-artifact: python-files
|
|
153
|
+
```
|
|
154
|
+
|
|
129
155
|
# Help
|
|
130
156
|
|
|
131
157
|
```yaml
|
package/autorest/__init__.py
CHANGED
|
@@ -38,8 +38,7 @@ class Plugin(ABC):
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
class YamlUpdatePlugin(Plugin):
|
|
41
|
-
"""A plugin that update the YAML as input.
|
|
42
|
-
"""
|
|
41
|
+
"""A plugin that update the YAML as input."""
|
|
43
42
|
|
|
44
43
|
def process(self) -> bool:
|
|
45
44
|
# List the input file, should be only one
|
|
@@ -62,7 +61,7 @@ class YamlUpdatePlugin(Plugin):
|
|
|
62
61
|
def update_yaml(self, yaml_data: Dict[str, Any]) -> None:
|
|
63
62
|
"""The code-model-v4-no-tags yaml model tree.
|
|
64
63
|
|
|
65
|
-
:rtype:
|
|
64
|
+
:rtype: updated yaml
|
|
66
65
|
:raises Exception: Could raise any exception, stacktrace will be sent to autorest API
|
|
67
66
|
"""
|
|
68
67
|
raise NotImplementedError()
|
|
@@ -15,20 +15,25 @@ _LOGGER = logging.getLogger(__name__)
|
|
|
15
15
|
_BLACK_MODE = black.Mode()
|
|
16
16
|
_BLACK_MODE.line_length = 120
|
|
17
17
|
|
|
18
|
-
class BlackScriptPlugin(Plugin):
|
|
19
18
|
|
|
19
|
+
class BlackScriptPlugin(Plugin):
|
|
20
20
|
def __init__(self, autorestapi):
|
|
21
|
-
super(
|
|
21
|
+
super().__init__(autorestapi)
|
|
22
22
|
output_folder_uri = self._autorestapi.get_value("outputFolderUri")
|
|
23
23
|
if output_folder_uri.startswith("file:"):
|
|
24
24
|
output_folder_uri = output_folder_uri[5:]
|
|
25
|
-
if os.name ==
|
|
25
|
+
if os.name == "nt" and output_folder_uri.startswith("///"):
|
|
26
26
|
output_folder_uri = output_folder_uri[3:]
|
|
27
27
|
self.output_folder = Path(output_folder_uri)
|
|
28
28
|
|
|
29
29
|
def process(self) -> bool:
|
|
30
30
|
# apply format_file on every file in the output folder
|
|
31
|
-
list(
|
|
31
|
+
list(
|
|
32
|
+
map(
|
|
33
|
+
self.format_file,
|
|
34
|
+
[f for f in self.output_folder.glob("**/*") if f.is_file()],
|
|
35
|
+
)
|
|
36
|
+
)
|
|
32
37
|
return True
|
|
33
38
|
|
|
34
39
|
def format_file(self, full_path) -> None:
|
|
@@ -38,7 +43,9 @@ class BlackScriptPlugin(Plugin):
|
|
|
38
43
|
self._autorestapi.write_file(file, file_content)
|
|
39
44
|
return
|
|
40
45
|
try:
|
|
41
|
-
file_content = black.format_file_contents(
|
|
46
|
+
file_content = black.format_file_contents(
|
|
47
|
+
file_content, fast=True, mode=_BLACK_MODE
|
|
48
|
+
)
|
|
42
49
|
except black.NothingChanged:
|
|
43
50
|
pass
|
|
44
51
|
self._autorestapi.write_file(file, file_content)
|