@autorest/python 5.12.4 → 5.13.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.
Files changed (47) hide show
  1. package/ChangeLog.md +173 -109
  2. package/autorest/black/__init__.py +7 -1
  3. package/autorest/codegen/__init__.py +12 -2
  4. package/autorest/codegen/models/__init__.py +2 -1
  5. package/autorest/codegen/models/client.py +22 -19
  6. package/autorest/codegen/models/constant_schema.py +0 -4
  7. package/autorest/codegen/models/credential_schema.py +3 -3
  8. package/autorest/codegen/models/dictionary_schema.py +1 -1
  9. package/autorest/codegen/models/enum_schema.py +2 -2
  10. package/autorest/codegen/models/imports.py +90 -50
  11. package/autorest/codegen/models/list_schema.py +1 -1
  12. package/autorest/codegen/models/lro_operation.py +15 -9
  13. package/autorest/codegen/models/object_schema.py +2 -2
  14. package/autorest/codegen/models/operation.py +39 -30
  15. package/autorest/codegen/models/operation_group.py +5 -14
  16. package/autorest/codegen/models/paging_operation.py +9 -9
  17. package/autorest/codegen/models/parameter.py +37 -11
  18. package/autorest/codegen/models/parameter_list.py +11 -4
  19. package/autorest/codegen/models/primitive_schemas.py +2 -2
  20. package/autorest/codegen/models/property.py +1 -1
  21. package/autorest/codegen/models/request_builder.py +7 -6
  22. package/autorest/codegen/models/request_builder_parameter.py +5 -0
  23. package/autorest/codegen/models/request_builder_parameter_list.py +1 -0
  24. package/autorest/codegen/models/schema_response.py +1 -1
  25. package/autorest/codegen/serializers/__init__.py +75 -71
  26. package/autorest/codegen/serializers/builder_serializer.py +68 -37
  27. package/autorest/codegen/serializers/client_serializer.py +14 -3
  28. package/autorest/codegen/serializers/general_serializer.py +7 -7
  29. package/autorest/codegen/serializers/import_serializer.py +44 -46
  30. package/autorest/codegen/serializers/metadata_serializer.py +12 -10
  31. package/autorest/codegen/serializers/utils.py +5 -1
  32. package/autorest/codegen/templates/config.py.jinja2 +2 -7
  33. package/autorest/codegen/templates/lro_operation.py.jinja2 +3 -1
  34. package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +2 -0
  35. package/autorest/codegen/templates/operation.py.jinja2 +8 -2
  36. package/autorest/codegen/templates/operation_group.py.jinja2 +2 -1
  37. package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -0
  38. package/autorest/codegen/templates/operation_tools.jinja2 +3 -2
  39. package/autorest/codegen/templates/paging_operation.py.jinja2 +3 -1
  40. package/autorest/codegen/templates/request_builder.py.jinja2 +2 -7
  41. package/autorest/codegen/templates/service_client.py.jinja2 +1 -1
  42. package/autorest/multiapi/models/imports.py +1 -1
  43. package/autorest/multiapi/serializers/import_serializer.py +1 -1
  44. package/autorest/namer/name_converter.py +1 -1
  45. package/package.json +2 -2
  46. package/run-python3.js +1 -7
  47. package/venvtools.py +2 -2
package/ChangeLog.md CHANGED
@@ -1,43 +1,103 @@
1
1
  # Change Log
2
2
 
3
+ ### 2022-03-03 - 5.13.0
4
+
5
+ | Library | Min Version |
6
+ | ----------------------------------------------------------------------- | ----------- |
7
+ | `@autorest/core` | `3.6.2` |
8
+ | `@autorest/modelerfour` | `4.19.1` |
9
+ | `azure-core` dep of generated code | `1.20.1` |
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 Generation**
14
+
15
+ - We now generate with optional constant parameters as None by defaulting `--default-optional-constants-to-none` to True #1171
16
+ - Version tolerant paging does not reformat initial query parameters into the next link #1168
17
+
18
+ **New Features**
19
+
20
+ - Add flag `--default-optional-constants-to-none` with which optional constant parameters is default to None #1171
21
+ - Add flag `--reformat-next-link`, determines whether we reformat initial query parameters into the next link. Defaults to `True` for the GA generator, forced to `False` for `--version-tolerant`.
22
+
23
+ **Bug Fixes**
24
+
25
+ - Add default value consistently for parameters #1164
26
+ - Make `content_type` param keyword-only if there are multiple content types #1167
27
+
28
+ **Other Changes**
29
+
30
+ - Drop testing support for 2.7 packages #1175
31
+
32
+ ### 2022-02-09 - 5.12.6
33
+
34
+ | Library | Min Version |
35
+ | ----------------------------------------------------------------------- | ----------- |
36
+ | `@autorest/core` | `3.6.2` |
37
+ | `@autorest/modelerfour` | `4.19.1` |
38
+ | `azure-core` dep of generated code | `1.20.1` |
39
+ | `msrest` dep of generated code | `0.6.21` |
40
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
41
+
42
+ **Bug Fixes**
43
+
44
+ - Remove unused `metadata` value for paging and long running operations with `version-tolerant` generations #1131
45
+ - Remove name conflicts with parameters called `url`, `header_parameters`, and `query_parameters` #1143
46
+ - Make `--version-tolerant` generated code pylint compatible in the `azure-sdk-for-python` repo when generated with the `--black` flag #1147, #1144, #1130
47
+
48
+ ### 2022-01-26 - 5.12.5
49
+
50
+ | Library | Min Version |
51
+ | ----------------------------------------------------------------------- | ----------- |
52
+ | `@autorest/core` | `3.6.2` |
53
+ | `@autorest/modelerfour` | `4.19.1` |
54
+ | `azure-core` dep of generated code | `1.20.1` |
55
+ | `msrest` dep of generated code | `0.6.21` |
56
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
57
+
58
+ **Bug Fixes**
59
+
60
+ - Fix usage of `--black` flag outside of repo #1126
61
+ - Remove unused `metadata` value for `version-tolerant` generations #1127
62
+
3
63
  ### 2022-01-14 - 5.12.4
4
64
 
5
- | Library | Min Version
6
- | --------------- | -------
7
- |`@autorest/core` | `3.6.2`
8
- |`@autorest/modelerfour` | `4.19.1`
9
- |`azure-core` dep of generated code | `1.20.1`
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`
65
+ | Library | Min Version |
66
+ | ----------------------------------------------------------------------- | ----------- |
67
+ | `@autorest/core` | `3.6.2` |
68
+ | `@autorest/modelerfour` | `4.19.1` |
69
+ | `azure-core` dep of generated code | `1.20.1` |
70
+ | `msrest` dep of generated code | `0.6.21` |
71
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
12
72
 
13
73
  **Bug Fixes**
14
74
 
15
- - Remove duplicate generation of properties in classes that inherit from multiple classes #1120
75
+ - Remove duplicate generation of properties in classes that inherit from multiple classes #1120
16
76
 
17
77
  ### 2022-01-13 - 5.12.3
18
78
 
19
- | Library | Min Version
20
- | --------------- | -------
21
- |`@autorest/core` | `3.6.2`
22
- |`@autorest/modelerfour` | `4.19.1`
23
- |`azure-core` dep of generated code | `1.20.1`
24
- |`msrest` dep of generated code | `0.6.21`
25
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
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.20.1` |
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` |
26
86
 
27
87
  **Bug Fixes**
28
88
 
29
- - Unify multiapi constant behavior with single API version #1119
30
- - Clean up docstrings by removing descriptions for client constants on methods and request builders #1119
89
+ - Unify multiapi constant behavior with single API version #1119
90
+ - Clean up docstrings by removing descriptions for client constants on methods and request builders #1119
31
91
 
32
92
  ### 2022-01-11 - 5.12.2
33
93
 
34
- | Library | Min Version
35
- | --------------- | -------
36
- |`@autorest/core` | `3.6.2`
37
- |`@autorest/modelerfour` | `4.19.1`
38
- |`azure-core` dep of generated code | `1.20.1`
39
- |`msrest` dep of generated code | `0.6.21`
40
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
94
+ | Library | Min Version |
95
+ | ----------------------------------------------------------------------- | ----------- |
96
+ | `@autorest/core` | `3.6.2` |
97
+ | `@autorest/modelerfour` | `4.19.1` |
98
+ | `azure-core` dep of generated code | `1.20.1` |
99
+ | `msrest` dep of generated code | `0.6.21` |
100
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
41
101
 
42
102
  **Bug Fixes**
43
103
 
@@ -45,81 +105,81 @@
45
105
 
46
106
  ### 2022-01-10 - 5.12.1
47
107
 
48
- | Library | Min Version
49
- | --------------- | -------
50
- |`@autorest/core` | `3.6.2`
51
- |`@autorest/modelerfour` | `4.19.1`
52
- |`azure-core` dep of generated code | `1.20.1`
53
- |`msrest` dep of generated code | `0.6.21`
54
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
108
+ | Library | Min Version |
109
+ | ----------------------------------------------------------------------- | ----------- |
110
+ | `@autorest/core` | `3.6.2` |
111
+ | `@autorest/modelerfour` | `4.19.1` |
112
+ | `azure-core` dep of generated code | `1.20.1` |
113
+ | `msrest` dep of generated code | `0.6.21` |
114
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
55
115
 
56
116
  **Bug Fixes**
57
117
 
58
- - Fix support for json merge patch #1117
118
+ - Fix support for json merge patch #1117
59
119
 
60
120
  ### 2021-12-06 - 5.12.0
61
121
 
62
- | Library | Min Version
63
- | --------------- | -------
64
- |`@autorest/core` | `3.6.2`
65
- |`@autorest/modelerfour` | `4.19.1`
66
- |`azure-core` dep of generated code | `1.20.1`
67
- |`msrest` dep of generated code | `0.6.21`
68
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
122
+ | Library | Min Version |
123
+ | ----------------------------------------------------------------------- | ----------- |
124
+ | `@autorest/core` | `3.6.2` |
125
+ | `@autorest/modelerfour` | `4.19.1` |
126
+ | `azure-core` dep of generated code | `1.20.1` |
127
+ | `msrest` dep of generated code | `0.6.21` |
128
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
69
129
 
70
130
  **Breaking Changes in Version Tolerant Generation**
71
131
 
72
132
  - Remove metadata property for version tolerant and low level client generations #1090
73
- - Generate SDKs with `--python3-only` defaulting to `True` for version tolerant and low level client #1087
133
+ - Generate SDKs with `--python3-only` defaulting to `True` for version tolerant and low level client #1087
74
134
 
75
135
  **New Features**
76
136
 
77
- - Generate a `_patch.py` file if one does not exist. These files are used to customize the generated code #1092
137
+ - Generate a `_patch.py` file if one does not exist. These files are used to customize the generated code #1092
78
138
 
79
139
  **Bug Fixes**
80
140
 
81
141
  - Can now handle body params with names `json`, `content`, `data`, and `files` #1081
82
- - Improve generated templates for `data` and `files` input body params by adding quotes around the keys #1082
83
- - Using flag `--python3-only` will get you typed sync client and config files #1085
84
- - Pin `mistune` dependency to less than `2.x.x` so autorest can be successfully installed #1106
142
+ - Improve generated templates for `data` and `files` input body params by adding quotes around the keys #1082
143
+ - Using flag `--python3-only` will get you typed sync client and config files #1085
144
+ - Pin `mistune` dependency to less than `2.x.x` so autorest can be successfully installed #1106
85
145
 
86
146
  ### 2021-11-05 - 5.11.2
87
147
 
88
- | Library | Min Version
89
- | --------------- | -------
90
- |`@autorest/core` | `3.6.2`
91
- |`@autorest/modelerfour` | `4.19.1`
92
- |`azure-core` dep of generated code | `1.20.0`
93
- |`msrest` dep of generated code | `0.6.21`
94
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
148
+ | Library | Min Version |
149
+ | ----------------------------------------------------------------------- | ----------- |
150
+ | `@autorest/core` | `3.6.2` |
151
+ | `@autorest/modelerfour` | `4.19.1` |
152
+ | `azure-core` dep of generated code | `1.20.0` |
153
+ | `msrest` dep of generated code | `0.6.21` |
154
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
95
155
 
96
156
  **Bug Fixes**
97
157
 
98
- - Respect no client side validation for low level client generations #1080
158
+ - Respect no client side validation for low level client generations #1080
99
159
 
100
160
  ### 2021-11-05 - 5.11.1
101
161
 
102
- | Library | Min Version
103
- | --------------- | -------
104
- |`@autorest/core` | `3.6.2`
105
- |`@autorest/modelerfour` | `4.19.1`
106
- |`azure-core` dep of generated code | `1.20.0`
107
- |`msrest` dep of generated code | `0.6.21`
108
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
162
+ | Library | Min Version |
163
+ | ----------------------------------------------------------------------- | ----------- |
164
+ | `@autorest/core` | `3.6.2` |
165
+ | `@autorest/modelerfour` | `4.19.1` |
166
+ | `azure-core` dep of generated code | `1.20.0` |
167
+ | `msrest` dep of generated code | `0.6.21` |
168
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
109
169
 
110
170
  **Bug Fixes**
111
171
 
112
- - Hide mixin operations for version tolerant generation #1071
172
+ - Hide mixin operations for version tolerant generation #1071
113
173
 
114
174
  ### 2021-11-04 - 5.11.0
115
175
 
116
- | Library | Min Version
117
- | --------------- | -------
118
- |`@autorest/core` | `3.6.2`
119
- |`@autorest/modelerfour` | `4.19.1`
120
- |`azure-core` dep of generated code | `1.20.0`
121
- |`msrest` dep of generated code | `0.6.21`
122
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
176
+ | Library | Min Version |
177
+ | ----------------------------------------------------------------------- | ----------- |
178
+ | `@autorest/core` | `3.6.2` |
179
+ | `@autorest/modelerfour` | `4.19.1` |
180
+ | `azure-core` dep of generated code | `1.20.0` |
181
+ | `msrest` dep of generated code | `0.6.21` |
182
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
123
183
 
124
184
  **New Features**
125
185
 
@@ -133,68 +193,69 @@
133
193
 
134
194
  ### 2021-11-01 - 5.10.0
135
195
 
136
- | Library | Min Version
137
- | --------------- | -------
138
- |`@autorest/core` | `3.6.2`
139
- |`@autorest/modelerfour` | `4.19.1`
140
- |`azure-core` dep of generated code | `1.19.1`
141
- |`msrest` dep of generated code | `0.6.21`
142
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
196
+ | Library | Min Version |
197
+ | ----------------------------------------------------------------------- | ----------- |
198
+ | `@autorest/core` | `3.6.2` |
199
+ | `@autorest/modelerfour` | `4.19.1` |
200
+ | `azure-core` dep of generated code | `1.19.1` |
201
+ | `msrest` dep of generated code | `0.6.21` |
202
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
143
203
 
144
204
  **New Features**
145
205
 
146
- - Allow users to override constant swagger params with kwarg input #1060
206
+ - Allow users to override constant swagger params with kwarg input #1060
147
207
 
148
208
  ### 2021-10-15 - 5.9.3
149
209
 
150
- | Library | Min Version
151
- | --------------- | -------
152
- |`@autorest/core` | `3.6.2`
153
- |`@autorest/modelerfour` | `4.19.1`
154
- |`azure-core` dep of generated code | `1.19.0`
155
- |`msrest` dep of generated code | `0.6.21`
156
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
210
+ | Library | Min Version |
211
+ | ----------------------------------------------------------------------- | ----------- |
212
+ | `@autorest/core` | `3.6.2` |
213
+ | `@autorest/modelerfour` | `4.19.1` |
214
+ | `azure-core` dep of generated code | `1.19.0` |
215
+ | `msrest` dep of generated code | `0.6.21` |
216
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
157
217
 
158
218
  **Bug Fixes**
159
219
 
160
- - Fix generation of form-data inputs #1061
220
+ - Fix generation of form-data inputs #1061
161
221
 
162
222
  ### 2021-10-05 - 5.9.2
163
223
 
164
- | Library | Min Version
165
- | --------------- | -------
166
- |`@autorest/core` | `3.6.2`
167
- |`@autorest/modelerfour` | `4.19.1`
168
- |`azure-core` dep of generated code | `1.19.0`
169
- |`msrest` dep of generated code | `0.6.21`
170
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
224
+ | Library | Min Version |
225
+ | ----------------------------------------------------------------------- | ----------- |
226
+ | `@autorest/core` | `3.6.2` |
227
+ | `@autorest/modelerfour` | `4.19.1` |
228
+ | `azure-core` dep of generated code | `1.19.0` |
229
+ | `msrest` dep of generated code | `0.6.21` |
230
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
171
231
 
172
232
  **New Features**
233
+
173
234
  - Updating generated code for `azure-core` release `1.19.0`.
174
235
 
175
236
  ### 2021-09-27 - 5.9.1
176
237
 
177
- | Library | Min Version
178
- | --------------- | -------
179
- |`@autorest/core` | `3.6.2`
180
- |`@autorest/modelerfour` | `4.19.1`
181
- |`azure-core` dep of generated code | `1.18.0`
182
- |`msrest` dep of generated code | `0.6.21`
183
- |`azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0`
238
+ | Library | Min Version |
239
+ | ----------------------------------------------------------------------- | ----------- |
240
+ | `@autorest/core` | `3.6.2` |
241
+ | `@autorest/modelerfour` | `4.19.1` |
242
+ | `azure-core` dep of generated code | `1.18.0` |
243
+ | `msrest` dep of generated code | `0.6.21` |
244
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
184
245
 
185
246
  **New Features**
186
247
 
187
248
  - We have added a **provisional** `rest` layer to our generated code. We have also added the following **provisional** flags listed [here](https://github.com/Azure/autorest.python/wiki/Generating-Low-Level-Client#generate-a-low-level-client). #875
188
- - With this new release, we are also dropping support for Python 3.5 + async. #875
249
+ - With this new release, we are also dropping support for Python 3.5 + async. #875
189
250
  - For mgmt plan SDK, default policy changes from `BearerTokenCredentialPolicy` to `ARMChallengeAuthenticationPolicy`.
190
251
  - We now add tracing by default, the flag `--trace` now defaults to `True` if you have operations.
191
- - Added flag `--python3-only` for users looking to generate SDKs that only support Python 3 #1044
252
+ - Added flag `--python3-only` for users looking to generate SDKs that only support Python 3 #1044
192
253
 
193
254
  **Bug Fixes**
194
255
 
195
- - Correctly pad operation groups with reserved names with `Operations` #1005
196
- - Fix the generated docstrings for input kwargs of models #1026
197
- - Pass pipeline context to `msrest` in `failsafe_deserialize` so `msrest` has access to the context #1030
256
+ - Correctly pad operation groups with reserved names with `Operations` #1005
257
+ - Fix the generated docstrings for input kwargs of models #1026
258
+ - Pass pipeline context to `msrest` in `failsafe_deserialize` so `msrest` has access to the context #1030
198
259
 
199
260
  ### 2021-09-27 - 5.9.0
200
261
 
@@ -229,7 +290,7 @@ min Modelerfour version: 4.19.1
229
290
 
230
291
  **Bug Fixes**
231
292
 
232
- - We are now more lenient with our checks for the content type parameter #956
293
+ - We are now more lenient with our checks for the content type parameter #956
233
294
 
234
295
  ### 2021-06-16 - 5.8.1
235
296
 
@@ -240,7 +301,7 @@ min Modelerfour version: 4.19.1
240
301
  **Bug Fixes**
241
302
 
242
303
  - Fix optional properties with constant schemas. Now, properties that have constant schemas but are optional will not have the hardcoded constant value,
243
- but will default to its `x-ms-client-default` or `None` #952
304
+ but will default to its `x-ms-client-default` or `None` #952
244
305
 
245
306
  ### 2021-05-17 - 5.8.0
246
307
 
@@ -250,7 +311,7 @@ min Modelerfour version: 4.19.1
250
311
 
251
312
  **New Features**
252
313
 
253
- - Add support for parameters and properties that can be of type "Anything". #946
314
+ - Add support for parameters and properties that can be of type "Anything". #946
254
315
 
255
316
  ### 2021-04-20 - 5.7.0
256
317
 
@@ -270,7 +331,7 @@ min Modelerfour version: 4.15.456
270
331
 
271
332
  **Bug Fixes**
272
333
 
273
- - Fix docstrings so they don't get split on hyphens #931
334
+ - Fix docstrings so they don't get split on hyphens #931
274
335
 
275
336
  ### 2021-04-07 - 5.6.5
276
337
 
@@ -280,7 +341,7 @@ min Modelerfour version: 4.15.456
280
341
 
281
342
  **Bug Fixes**
282
343
 
283
- - Fix regression in multiapi generation for multiapi versions without mixin operations #928
344
+ - Fix regression in multiapi generation for multiapi versions without mixin operations #928
284
345
 
285
346
  ### 2021-03-01 - 5.6.4
286
347
 
@@ -289,6 +350,7 @@ min Autorest core version: 3.1.0
289
350
  min Modelerfour version: 4.15.456
290
351
 
291
352
  **Bug Fixes**
353
+
292
354
  - Bump `Autorest core` minimum version to be able to deal with indented `python` blocks in config files
293
355
 
294
356
  ### 2021-02-10 - 5.6.3
@@ -298,7 +360,8 @@ min Autorest core version: 3.0.6372
298
360
  min Modelerfour version: 4.15.456
299
361
 
300
362
  **Bug Fixes**
301
- - Bump `Autorest core` minimum version to [correctly deal with](https://github.com/Azure/autorest/pull/3860) overriding configs. Fixes submodule-specific code in our multiapi client #880
363
+
364
+ - Bump `Autorest core` minimum version to [correctly deal with](https://github.com/Azure/autorest/pull/3860) overriding configs. Fixes submodule-specific code in our multiapi client #880
302
365
 
303
366
  ### 2021-02-04 - 5.6.2
304
367
 
@@ -307,7 +370,8 @@ Autorest core version: 3.0.6318
307
370
  Modelerfour version: 4.15.456
308
371
 
309
372
  **Bug Fixes**
310
- - Bump `Modelerfour` minimum version to [correctly deal with](https://github.com/Azure/autorest.modelerfour/pull/385) parameters specified as `'required': false` in swagger #877
373
+
374
+ - Bump `Modelerfour` minimum version to [correctly deal with](https://github.com/Azure/autorest.modelerfour/pull/385) parameters specified as `'required': false` in swagger #877
311
375
 
312
376
  ### 2021-01-27 - 5.6.1
313
377
 
@@ -5,6 +5,7 @@
5
5
  # --------------------------------------------------------------------------
6
6
  import logging
7
7
  from pathlib import Path
8
+ import os
8
9
  import black
9
10
 
10
11
  from .. import Plugin
@@ -18,7 +19,12 @@ class BlackScriptPlugin(Plugin):
18
19
 
19
20
  def __init__(self, autorestapi):
20
21
  super(BlackScriptPlugin, self).__init__(autorestapi)
21
- self.output_folder: Path = Path(self._autorestapi.get_value("output-folder")).resolve()
22
+ output_folder_uri = self._autorestapi.get_value("outputFolderUri")
23
+ if output_folder_uri.startswith("file:"):
24
+ output_folder_uri = output_folder_uri[5:]
25
+ if os.name == 'nt' and output_folder_uri.startswith("///"):
26
+ output_folder_uri = output_folder_uri[3:]
27
+ self.output_folder = Path(output_folder_uri)
22
28
 
23
29
  def process(self) -> bool:
24
30
  # apply format_file on every file in the output folder
@@ -76,6 +76,12 @@ def _validate_code_model_options(options: Dict[str, Any]) -> None:
76
76
  "If you want operation files, pass in flag --show-operations"
77
77
  )
78
78
 
79
+ if options["reformat_next_link"] and options["version_tolerant"]:
80
+ raise ValueError(
81
+ "--reformat-next-link can not be true for version tolerant generations. "
82
+ "Please remove --reformat-next-link from your call for version tolerant generations."
83
+ )
84
+
79
85
  _LOGGER = logging.getLogger(__name__)
80
86
  class CodeGenerator(Plugin):
81
87
  @staticmethod
@@ -289,6 +295,10 @@ class CodeGenerator(Plugin):
289
295
  "low_level_client": low_level_client,
290
296
  "combine_operation_files": self._autorestapi.get_boolean_value("combine-operation-files", version_tolerant),
291
297
  "python3_only": python3_only,
298
+ "default_optional_constants_to_none": self._autorestapi.get_boolean_value(
299
+ "default-optional-constants-to-none", low_level_client or version_tolerant
300
+ ),
301
+ "reformat_next_link": self._autorestapi.get_boolean_value("reformat-next-link", not version_tolerant)
292
302
  }
293
303
 
294
304
  if options["builders_visibility"] is None:
@@ -327,8 +337,8 @@ class CodeGenerator(Plugin):
327
337
 
328
338
  code_model = self._create_code_model(yaml_data=yaml_data, options=options)
329
339
 
330
- serializer = JinjaSerializer(self._autorestapi)
331
- serializer.serialize(code_model)
340
+ serializer = JinjaSerializer(self._autorestapi, code_model)
341
+ serializer.serialize()
332
342
 
333
343
  return True
334
344
 
@@ -17,7 +17,7 @@ from .constant_schema import ConstantSchema
17
17
  from .imports import FileImport, ImportType, TypingSection
18
18
  from .lro_operation import LROOperation
19
19
  from .paging_operation import PagingOperation
20
- from .parameter import Parameter, ParameterStyle
20
+ from .parameter import Parameter, ParameterStyle, ParameterLocation
21
21
  from .operation import Operation
22
22
  from .property import Property
23
23
  from .operation_group import OperationGroup
@@ -50,6 +50,7 @@ __all__ = [
50
50
  "PagingOperation",
51
51
  "Parameter",
52
52
  "ParameterList",
53
+ "ParameterLocation",
53
54
  "OperationGroup",
54
55
  "Property",
55
56
  "RequestBuilder",
@@ -33,27 +33,28 @@ class Client:
33
33
  def _imports_shared(self, async_mode: bool) -> FileImport:
34
34
  file_import = FileImport()
35
35
 
36
- file_import.add_from_import("msrest", "Serializer", ImportType.AZURECORE)
37
- file_import.add_from_import("msrest", "Deserializer", ImportType.AZURECORE)
38
- file_import.add_from_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL)
36
+ file_import.add_submodule_import("msrest", "Serializer", ImportType.THIRDPARTY)
37
+ file_import.add_submodule_import("msrest", "Deserializer", ImportType.THIRDPARTY)
38
+ file_import.add_submodule_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL)
39
39
 
40
40
  any_optional_gp = any(not gp.required for gp in self.parameters)
41
41
 
42
- if any_optional_gp or self.code_model.service_client.parameters.host:
43
- file_import.add_from_import("typing", "Optional", ImportType.STDLIB, TypingSection.CONDITIONAL)
42
+ legacy = not any(g for g in ["low_level_client", "version_tolerant"] if g in self.code_model.options)
43
+ if any_optional_gp or (legacy and self.code_model.service_client.parameters.host):
44
+ file_import.add_submodule_import("typing", "Optional", ImportType.STDLIB, TypingSection.CONDITIONAL)
44
45
 
45
46
  if self.code_model.options["azure_arm"]:
46
- file_import.add_from_import(
47
+ file_import.add_submodule_import(
47
48
  "azure.mgmt.core", self.pipeline_class(async_mode), ImportType.AZURECORE
48
49
  )
49
50
  else:
50
- file_import.add_from_import(
51
+ file_import.add_submodule_import(
51
52
  "azure.core", self.pipeline_class(async_mode), ImportType.AZURECORE
52
53
  )
53
54
 
54
55
  for gp in self.code_model.global_parameters:
55
56
  file_import.merge(gp.imports())
56
- file_import.add_from_import(
57
+ file_import.add_submodule_import(
57
58
  "._configuration", f"{self.code_model.class_name}Configuration",
58
59
  ImportType.LOCAL
59
60
  )
@@ -63,39 +64,41 @@ class Client:
63
64
  def imports(self, async_mode: bool) -> FileImport:
64
65
  file_import = self._imports_shared(async_mode)
65
66
  if async_mode:
66
- file_import.add_from_import("typing", "Awaitable", ImportType.STDLIB)
67
- file_import.add_from_import(
67
+ file_import.add_submodule_import("typing", "Awaitable", ImportType.STDLIB)
68
+ file_import.add_submodule_import(
68
69
  "azure.core.rest", "AsyncHttpResponse", ImportType.AZURECORE, TypingSection.CONDITIONAL
69
70
  )
70
71
  else:
71
- file_import.add_from_import(
72
+ file_import.add_submodule_import(
72
73
  "azure.core.rest", "HttpResponse", ImportType.AZURECORE, TypingSection.CONDITIONAL
73
74
  )
74
- file_import.add_from_import("azure.core.rest", "HttpRequest", ImportType.AZURECORE, TypingSection.CONDITIONAL)
75
+ file_import.add_submodule_import(
76
+ "azure.core.rest", "HttpRequest", ImportType.AZURECORE, TypingSection.CONDITIONAL
77
+ )
75
78
  for og in self.code_model.operation_groups:
76
- file_import.add_from_import(
79
+ file_import.add_submodule_import(
77
80
  f".{self.code_model.operations_folder_name}", og.class_name, ImportType.LOCAL
78
81
  )
79
82
 
80
83
  if self.code_model.sorted_schemas:
81
84
  path_to_models = ".." if async_mode else "."
82
- file_import.add_from_import(path_to_models, "models", ImportType.LOCAL)
85
+ file_import.add_submodule_import(path_to_models, "models", ImportType.LOCAL)
83
86
  else:
84
87
  # in this case, we have client_models = {} in the service client, which needs a type annotation
85
88
  # this import will always be commented, so will always add it to the typing section
86
- file_import.add_from_import("typing", "Dict", ImportType.STDLIB, TypingSection.TYPING)
87
- file_import.add_from_import("copy", "deepcopy", ImportType.STDLIB)
89
+ file_import.add_submodule_import("typing", "Dict", ImportType.STDLIB, TypingSection.TYPING)
90
+ file_import.add_submodule_import("copy", "deepcopy", ImportType.STDLIB)
88
91
  return file_import
89
92
 
90
93
  def imports_for_multiapi(self, async_mode: bool) -> FileImport:
91
94
  file_import = self._imports_shared(async_mode)
92
95
  try:
93
96
  mixin_operation = next(og for og in self.code_model.operation_groups if og.is_empty_operation_group)
94
- file_import.add_from_import("._operations_mixin", mixin_operation.class_name, ImportType.LOCAL)
97
+ file_import.add_submodule_import("._operations_mixin", mixin_operation.class_name, ImportType.LOCAL)
95
98
  except StopIteration:
96
99
  pass
97
100
  return file_import
98
101
 
99
- def send_request_signature(self, async_mode: bool, is_python3_file: bool) -> List[str]:
100
- request_signature = ["request: HttpRequest," if async_mode else "request, # type: HttpRequest"]
102
+ def send_request_signature(self, is_python3_file: bool) -> List[str]:
103
+ request_signature = ["request: HttpRequest," if is_python3_file else "request, # type: HttpRequest"]
101
104
  return request_signature + self.parameters.method_signature_kwargs(is_python3_file)
@@ -39,10 +39,6 @@ class ConstantSchema(BaseSchema):
39
39
  return "None"
40
40
  return self.schema.get_declaration(self.value)
41
41
 
42
- @property
43
- def extra_description_information(self) -> str:
44
- return f"The default value is {self.get_declaration(self.value)}."
45
-
46
42
  @property
47
43
  def serialization_type(self) -> str:
48
44
  """Returns the serialization value for msrest.
@@ -44,7 +44,7 @@ class AzureKeyCredentialSchema(CredentialSchema):
44
44
 
45
45
  def imports(self) -> FileImport:
46
46
  file_import = FileImport()
47
- file_import.add_from_import(
47
+ file_import.add_submodule_import(
48
48
  "azure.core.credentials",
49
49
  "AzureKeyCredential",
50
50
  ImportType.AZURECORE,
@@ -76,13 +76,13 @@ class TokenCredentialSchema(CredentialSchema):
76
76
  def imports(self) -> FileImport:
77
77
  file_import = FileImport()
78
78
  if self.async_mode:
79
- file_import.add_from_import(
79
+ file_import.add_submodule_import(
80
80
  "azure.core.credentials_async", "AsyncTokenCredential",
81
81
  ImportType.AZURECORE,
82
82
  typing_section=TypingSection.TYPING
83
83
  )
84
84
  else:
85
- file_import.add_from_import(
85
+ file_import.add_submodule_import(
86
86
  "azure.core.credentials", "TokenCredential",
87
87
  ImportType.AZURECORE,
88
88
  typing_section=TypingSection.TYPING
@@ -98,6 +98,6 @@ class DictionarySchema(BaseSchema):
98
98
 
99
99
  def imports(self) -> FileImport:
100
100
  file_import = FileImport()
101
- file_import.add_from_import("typing", "Dict", ImportType.STDLIB, TypingSection.CONDITIONAL)
101
+ file_import.add_submodule_import("typing", "Dict", ImportType.STDLIB, TypingSection.CONDITIONAL)
102
102
  file_import.merge(self.element_type.imports())
103
103
  return file_import