@autorest/python 5.19.0 → 6.0.0-rc.1

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 (42) hide show
  1. package/ChangeLog.md +29 -2
  2. package/README.md +9 -0
  3. package/autorest/codegen/__init__.py +18 -29
  4. package/autorest/codegen/models/base_builder.py +17 -6
  5. package/autorest/codegen/models/client.py +1 -1
  6. package/autorest/codegen/models/code_model.py +7 -12
  7. package/autorest/codegen/models/lro_operation.py +2 -6
  8. package/autorest/codegen/models/lro_paging_operation.py +3 -9
  9. package/autorest/codegen/models/model_type.py +1 -6
  10. package/autorest/codegen/models/operation.py +6 -37
  11. package/autorest/codegen/models/operation_group.py +4 -7
  12. package/autorest/codegen/models/paging_operation.py +2 -6
  13. package/autorest/codegen/models/parameter.py +3 -7
  14. package/autorest/codegen/models/parameter_list.py +20 -36
  15. package/autorest/codegen/models/request_builder.py +0 -22
  16. package/autorest/codegen/serializers/__init__.py +3 -50
  17. package/autorest/codegen/serializers/builder_serializer.py +30 -36
  18. package/autorest/codegen/serializers/client_serializer.py +14 -31
  19. package/autorest/codegen/serializers/general_serializer.py +2 -7
  20. package/autorest/codegen/serializers/import_serializer.py +11 -22
  21. package/autorest/codegen/serializers/metadata_serializer.py +0 -2
  22. package/autorest/codegen/serializers/{model_base_serializer.py → model_serializer.py} +47 -38
  23. package/autorest/codegen/serializers/operation_groups_serializer.py +0 -7
  24. package/autorest/codegen/serializers/operations_init_serializer.py +2 -23
  25. package/autorest/codegen/serializers/patch_serializer.py +1 -3
  26. package/autorest/codegen/serializers/request_builders_serializer.py +1 -4
  27. package/autorest/codegen/serializers/utils.py +1 -4
  28. package/autorest/codegen/templates/client.py.jinja2 +3 -3
  29. package/autorest/codegen/templates/config.py.jinja2 +2 -2
  30. package/autorest/codegen/templates/metadata.json.jinja2 +4 -4
  31. package/autorest/codegen/templates/model_init.py.jinja2 +5 -12
  32. package/autorest/codegen/templates/operation_group.py.jinja2 +1 -1
  33. package/autorest/codegen/templates/operation_groups_container.py.jinja2 +0 -6
  34. package/autorest/codegen/templates/patch.py.jinja2 +1 -2
  35. package/autorest/codegen/templates/request_builders.py.jinja2 +0 -3
  36. package/autorest/codegen/templates/rest_init.py.jinja2 +3 -8
  37. package/autorest/m4reformatter/__init__.py +9 -3
  38. package/autorest/multiapi/serializers/__init__.py +3 -8
  39. package/autorest/multiapi/serializers/import_serializer.py +4 -8
  40. package/package.json +2 -2
  41. package/autorest/codegen/serializers/model_generic_serializer.py +0 -32
  42. package/autorest/codegen/serializers/model_python3_serializer.py +0 -72
@@ -1,72 +0,0 @@
1
- # -------------------------------------------------------------------------
2
- # Copyright (c) Microsoft Corporation. All rights reserved.
3
- # Licensed under the MIT License. See License.txt in the project root for
4
- # license information.
5
- # --------------------------------------------------------------------------
6
- from typing import List
7
- from jinja2 import Environment
8
- from .model_base_serializer import ModelBaseSerializer
9
- from ..models import ModelType, CodeModel, Property
10
- from ..models.imports import FileImport
11
-
12
-
13
- class ModelPython3Serializer(ModelBaseSerializer):
14
- def __init__(self, code_model: CodeModel, env: Environment) -> None:
15
- super().__init__(code_model=code_model, env=env, is_python3_file=True)
16
-
17
- def init_line(self, model: ModelType) -> List[str]:
18
- init_properties_declaration = []
19
- init_line_parameters = [
20
- p
21
- for p in model.properties
22
- if not p.readonly and not p.is_discriminator and not p.constant
23
- ]
24
- init_line_parameters.sort(key=lambda x: x.optional)
25
- if init_line_parameters:
26
- init_properties_declaration.append("*,")
27
- for param in init_line_parameters:
28
- init_properties_declaration.append(self.initialize_standard_property(param))
29
-
30
- return init_properties_declaration
31
-
32
- def properties_to_pass_to_super(self, model: ModelType) -> str:
33
- properties_to_pass_to_super = []
34
- for parent in model.parents:
35
- for prop in model.properties:
36
- if (
37
- prop in parent.properties
38
- and not prop.is_discriminator
39
- and not prop.constant
40
- and not prop.readonly
41
- ):
42
- properties_to_pass_to_super.append(
43
- f"{prop.client_name}={prop.client_name}"
44
- )
45
- properties_to_pass_to_super.append("**kwargs")
46
- return ", ".join(properties_to_pass_to_super)
47
-
48
- def required_property_no_default_init(self, prop: Property) -> str:
49
- return f"{prop.client_name}: {prop.type_annotation()},{prop.pylint_disable}"
50
-
51
- def optional_property_init(self, prop: Property) -> str:
52
- return (
53
- f"{prop.client_name}: {prop.type_annotation()} = "
54
- f"{prop.client_default_value_declaration},{prop.pylint_disable}"
55
- )
56
-
57
- def initialize_standard_arg(self, prop: Property) -> str:
58
- return f"self.{prop.client_name} = {prop.client_name}"
59
-
60
- def super_call_template(self, model: ModelType) -> str:
61
- return "super().__init__({})"
62
-
63
- def imports(self) -> FileImport:
64
- file_import = super(ModelPython3Serializer, self).imports()
65
- for model in self.code_model.model_types:
66
- init_line_parameters = [
67
- p for p in model.properties if not p.readonly and not p.is_discriminator
68
- ]
69
- for param in init_line_parameters:
70
- file_import.merge(param.imports())
71
-
72
- return file_import