@autorest/python 5.14.0 → 5.17.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 (120) hide show
  1. package/ChangeLog.md +91 -2
  2. package/README.md +30 -4
  3. package/autorest/__init__.py +2 -3
  4. package/autorest/black/__init__.py +12 -5
  5. package/autorest/codegen/__init__.py +130 -179
  6. package/autorest/codegen/models/__init__.py +122 -78
  7. package/autorest/codegen/models/base_builder.py +70 -72
  8. package/autorest/codegen/models/base_model.py +7 -5
  9. package/autorest/codegen/models/{base_schema.py → base_type.py} +62 -49
  10. package/autorest/codegen/models/client.py +195 -36
  11. package/autorest/codegen/models/code_model.py +165 -299
  12. package/autorest/codegen/models/combined_type.py +107 -0
  13. package/autorest/codegen/models/constant_type.py +122 -0
  14. package/autorest/codegen/models/credential_types.py +224 -0
  15. package/autorest/codegen/models/dictionary_type.py +116 -0
  16. package/autorest/codegen/models/enum_type.py +195 -0
  17. package/autorest/codegen/models/imports.py +95 -41
  18. package/autorest/codegen/models/list_type.py +134 -0
  19. package/autorest/codegen/models/lro_operation.py +90 -133
  20. package/autorest/codegen/models/lro_paging_operation.py +28 -12
  21. package/autorest/codegen/models/model_type.py +239 -0
  22. package/autorest/codegen/models/operation.py +415 -241
  23. package/autorest/codegen/models/operation_group.py +82 -88
  24. package/autorest/codegen/models/paging_operation.py +101 -117
  25. package/autorest/codegen/models/parameter.py +307 -322
  26. package/autorest/codegen/models/parameter_list.py +366 -357
  27. package/autorest/codegen/models/primitive_types.py +544 -0
  28. package/autorest/codegen/models/property.py +122 -134
  29. package/autorest/codegen/models/request_builder.py +138 -86
  30. package/autorest/codegen/models/request_builder_parameter.py +122 -79
  31. package/autorest/codegen/models/response.py +325 -0
  32. package/autorest/codegen/models/utils.py +17 -1
  33. package/autorest/codegen/serializers/__init__.py +242 -118
  34. package/autorest/codegen/serializers/builder_serializer.py +863 -1027
  35. package/autorest/codegen/serializers/client_serializer.py +148 -82
  36. package/autorest/codegen/serializers/general_serializer.py +44 -47
  37. package/autorest/codegen/serializers/import_serializer.py +96 -31
  38. package/autorest/codegen/serializers/metadata_serializer.py +39 -79
  39. package/autorest/codegen/serializers/model_base_serializer.py +65 -29
  40. package/autorest/codegen/serializers/model_generic_serializer.py +9 -10
  41. package/autorest/codegen/serializers/model_init_serializer.py +4 -2
  42. package/autorest/codegen/serializers/model_python3_serializer.py +29 -22
  43. package/autorest/codegen/serializers/operation_groups_serializer.py +21 -18
  44. package/autorest/codegen/serializers/operations_init_serializer.py +23 -11
  45. package/autorest/codegen/serializers/parameter_serializer.py +174 -0
  46. package/autorest/codegen/serializers/patch_serializer.py +14 -2
  47. package/autorest/codegen/serializers/request_builders_serializer.py +57 -0
  48. package/autorest/codegen/serializers/utils.py +0 -103
  49. package/autorest/codegen/templates/MANIFEST.in.jinja2 +1 -0
  50. package/autorest/codegen/templates/{service_client.py.jinja2 → client.py.jinja2} +7 -7
  51. package/autorest/codegen/templates/config.py.jinja2 +13 -13
  52. package/autorest/codegen/templates/enum.py.jinja2 +4 -4
  53. package/autorest/codegen/templates/enum_container.py.jinja2 +1 -2
  54. package/autorest/codegen/templates/init.py.jinja2 +9 -6
  55. package/autorest/codegen/templates/keywords.jinja2 +14 -1
  56. package/autorest/codegen/templates/lro_operation.py.jinja2 +6 -5
  57. package/autorest/codegen/templates/lro_paging_operation.py.jinja2 +6 -5
  58. package/autorest/codegen/templates/metadata.json.jinja2 +36 -35
  59. package/autorest/codegen/templates/model.py.jinja2 +23 -29
  60. package/autorest/codegen/templates/model_container.py.jinja2 +2 -1
  61. package/autorest/codegen/templates/model_init.py.jinja2 +9 -8
  62. package/autorest/codegen/templates/operation.py.jinja2 +10 -15
  63. package/autorest/codegen/templates/operation_group.py.jinja2 +14 -13
  64. package/autorest/codegen/templates/operation_groups_container.py.jinja2 +1 -2
  65. package/autorest/codegen/templates/operation_tools.jinja2 +8 -2
  66. package/autorest/codegen/templates/operations_folder_init.py.jinja2 +4 -0
  67. package/autorest/codegen/templates/paging_operation.py.jinja2 +7 -8
  68. package/autorest/codegen/templates/patch.py.jinja2 +18 -29
  69. package/autorest/codegen/templates/request_builder.py.jinja2 +20 -13
  70. package/autorest/codegen/templates/setup.py.jinja2 +9 -3
  71. package/autorest/codegen/templates/vendor.py.jinja2 +12 -2
  72. package/autorest/jsonrpc/__init__.py +7 -12
  73. package/autorest/jsonrpc/localapi.py +4 -3
  74. package/autorest/jsonrpc/server.py +28 -9
  75. package/autorest/jsonrpc/stdstream.py +13 -6
  76. package/autorest/m2r/__init__.py +5 -8
  77. package/autorest/m4reformatter/__init__.py +1108 -0
  78. package/autorest/multiapi/__init__.py +24 -14
  79. package/autorest/multiapi/models/client.py +21 -11
  80. package/autorest/multiapi/models/code_model.py +23 -10
  81. package/autorest/multiapi/models/config.py +4 -1
  82. package/autorest/multiapi/models/constant_global_parameter.py +1 -0
  83. package/autorest/multiapi/models/global_parameter.py +2 -1
  84. package/autorest/multiapi/models/global_parameters.py +14 -8
  85. package/autorest/multiapi/models/imports.py +35 -18
  86. package/autorest/multiapi/models/mixin_operation.py +5 -5
  87. package/autorest/multiapi/models/operation_group.py +2 -1
  88. package/autorest/multiapi/models/operation_mixin_group.py +21 -10
  89. package/autorest/multiapi/serializers/__init__.py +20 -25
  90. package/autorest/multiapi/serializers/import_serializer.py +47 -15
  91. package/autorest/multiapi/serializers/multiapi_serializer.py +17 -17
  92. package/autorest/multiapi/templates/multiapi_config.py.jinja2 +3 -3
  93. package/autorest/multiapi/templates/multiapi_init.py.jinja2 +2 -2
  94. package/autorest/multiapi/templates/multiapi_operations_mixin.py.jinja2 +4 -4
  95. package/autorest/multiapi/templates/multiapi_service_client.py.jinja2 +9 -9
  96. package/autorest/multiapi/utils.py +3 -3
  97. package/autorest/postprocess/__init__.py +202 -0
  98. package/autorest/postprocess/get_all.py +19 -0
  99. package/autorest/postprocess/venvtools.py +73 -0
  100. package/autorest/preprocess/__init__.py +209 -0
  101. package/autorest/preprocess/helpers.py +54 -0
  102. package/autorest/{namer → preprocess}/python_mappings.py +25 -32
  103. package/package.json +3 -3
  104. package/run-python3.js +2 -3
  105. package/venvtools.py +1 -1
  106. package/autorest/codegen/models/constant_schema.py +0 -97
  107. package/autorest/codegen/models/credential_schema.py +0 -90
  108. package/autorest/codegen/models/credential_schema_policy.py +0 -77
  109. package/autorest/codegen/models/dictionary_schema.py +0 -103
  110. package/autorest/codegen/models/enum_schema.py +0 -246
  111. package/autorest/codegen/models/list_schema.py +0 -113
  112. package/autorest/codegen/models/object_schema.py +0 -249
  113. package/autorest/codegen/models/primitive_schemas.py +0 -476
  114. package/autorest/codegen/models/request_builder_parameter_list.py +0 -280
  115. package/autorest/codegen/models/rest.py +0 -42
  116. package/autorest/codegen/models/schema_request.py +0 -45
  117. package/autorest/codegen/models/schema_response.py +0 -123
  118. package/autorest/codegen/serializers/rest_serializer.py +0 -57
  119. package/autorest/namer/__init__.py +0 -25
  120. package/autorest/namer/name_converter.py +0 -412
package/ChangeLog.md CHANGED
@@ -1,5 +1,94 @@
1
1
  # Change Log
2
2
 
3
+ ### 2022-06-02 - 5.17.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
+ **New Features**
14
+
15
+ - Hide `api_version` in doc string for singleapi SDK even if contains multi api versions #1239
16
+ - Add overloads for operations with different body types. We now sniff bodies and assign content type based off of body type. #1230
17
+ - Add flag `--postprocess`. Run this after doing customizations for full mypy support
18
+
19
+ **Breaking Changes in Version Tolerant**
20
+
21
+ - Have stream responses directly return an iterator of bytes, so you don't need to call `.iter_bytes()` on the response object. #1254
22
+ - If generating with `--models-mode=msrest` in version tolerant, we hide paging models #1259
23
+
24
+ **Breaking Changes in Request Builders**
25
+
26
+ - Request builders for LRO operations have the `_initial` suffix removed from their name #1241
27
+ - Request builders from groups with reserved words will now be padded with the word "Operations" instead of "Builders" #1243
28
+
29
+ **Bug Fixes**
30
+
31
+ - Make sure `any-object` schemas from swagger are typed with `MutableMapping`s #1243
32
+ - Make typing for parameters `Optional` only if `None` is a valid input, not only if it is specified as `optional` in swagger #1244
33
+ - Fix for render failure of `README.md` when `--package-mode==dataplane` #1247
34
+ - Fix typing for stream responses to iterators of bytes. #1254
35
+ - Additional linting support #1265
36
+ - Fix Sphinx documentation for raised exception #1264
37
+ - Use `api_version` in `_config` as default value for operation function #1268
38
+
39
+ **Other Changes**
40
+
41
+ - Update template files for `--package-mode` # 1248
42
+
43
+ ### 2022-04-18 - 5.16.0
44
+
45
+ | Library | Min Version |
46
+ | ----------------------------------------------------------------------- | ----------- |
47
+ | `@autorest/core` | `3.6.2` |
48
+ | `@autorest/modelerfour` | `4.19.1` |
49
+ | `azure-core` dep of generated code | `1.23.0` |
50
+ | `msrest` dep of generated code | `0.6.21` |
51
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
52
+
53
+ **Breaking Changes in Version Tolerant Generation**
54
+
55
+ - 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
56
+
57
+ **Bug Fixes**
58
+
59
+ - Drop package dependency on "@azure-tools/extension", switch to "@autorest/system-requirements" #1229
60
+ - Fix `content_type` generation in multiapi SDKs with multiple content types for bodies #1232
61
+
62
+ ### 2022-04-07 - 5.15.0
63
+
64
+ | Library | Min Version |
65
+ | ----------------------------------------------------------------------- | ----------- |
66
+ | `@autorest/core` | `3.6.2` |
67
+ | `@autorest/modelerfour` | `4.19.1` |
68
+ | `azure-core` dep of generated code | `1.23.0` |
69
+ | `msrest` dep of generated code | `0.6.21` |
70
+ | `azure-mgmt-core` dep of generated code (If generating mgmt plane code) | `1.3.0` |
71
+
72
+ **New Features**
73
+
74
+ - Add support for security configurations in the swagger. For more information, see https://github.com/Azure/autorest/blob/main/docs/generate/authentication.md #1161
75
+ - Add support for handwritten customizations of generated code. For more information, see https://aka.ms/azsdk/python/dpcodegen/python/customize #1153
76
+ - Allow `header` and `params` as kwargs in operation and request-build function to hand over REST Header and Query parameters case insensitively #1183
77
+ - Typing operation parameters as JSON, Primitives or Any for `--version-tolerant` #1210
78
+
79
+ **Bug Fixes**
80
+
81
+ - Make `--version-tolerant` generated code mypy compatible in the `azure-sdk-for-python` repo. Tested only with the `--black` flag #1185
82
+ - Remove unnecessary vendored code in the `_vendor` file if the SDK has no operations #1196
83
+ - Fix the generation of the root `__init__` files for packages with only models #1195
84
+ - Add pylint and mypy support for `--version-tolerant` generations with `--models-mode=msrest` #1202
85
+
86
+ **Breaking Changes in Version Tolerant Generation**
87
+
88
+ - Change client filenames to `_client.py` #1206
89
+ - Change the models filename from `_models_py3.py` to `_models.py` #1204
90
+ - Change the enums filename to `_enums.py` #1204
91
+
3
92
  ### 2022-03-08 - 5.14.0
4
93
 
5
94
  | Library | Min Version |
@@ -667,7 +756,7 @@ Modelerfour version: 4.13.351
667
756
  **Bug Fixes**
668
757
 
669
758
  - Corrected ordering of summary and description in generated methods #640
670
- - Have `IOSchema` call super init to get all of the properties shared in `BaseSchema` #642
759
+ - Have `IOSchema` call super init to get all of the properties shared in `BaseType` #642
671
760
 
672
761
  ### 2020-05-15 - 5.0.0-preview.7
673
762
 
@@ -812,7 +901,7 @@ Modelerfour version: 4.12.276
812
901
 
813
902
  - Will no longer permit generated enums and models to have the same name #504
814
903
  - No longer exposing models from operation groups without importing them #486
815
- - Now correctly deserializes error's that have an empty object (AnySchema) as a model #516
904
+ - Now correctly deserializes error's that have an empty object (AnyType) as a model #516
816
905
  - Added a list of parameter names to reserved parameter words, so there won't be clashes #525
817
906
  - If a property's schema is readonly, we will show that property as being readonly (taken from m4 update #234)
818
907
  - 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.6.2
41
+ version: ~3.8.1
38
42
  use-extension:
39
- "@autorest/modelerfour": ~4.19.1
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/namer:
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/namer
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
@@ -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: None
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(BlackScriptPlugin, self).__init__(autorestapi)
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 == 'nt' and output_folder_uri.startswith("///"):
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(map(self.format_file, [f for f in self.output_folder.glob('**/*') if f.is_file()]))
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(file_content, fast=True, mode=_BLACK_MODE)
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)