@autorest/python 6.7.5 → 6.7.7

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.
@@ -85,8 +85,6 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]):
85
85
  request_builders: List[Union[RequestBuilder, OverloadedRequestBuilder]] = []
86
86
  for og_group in self.yaml_data["operationGroups"]:
87
87
  for operation_yaml in og_group["operations"]:
88
- if operation_yaml["discriminator"] in ("lro", "lropaging"):
89
- continue
90
88
  request_builder = get_request_builder(
91
89
  operation_yaml,
92
90
  code_model=self.code_model,
@@ -65,7 +65,7 @@ class EnumType(BaseType):
65
65
  value_type: BaseType,
66
66
  ) -> None:
67
67
  super().__init__(yaml_data=yaml_data, code_model=code_model)
68
- self.name: str = yaml_data["name"]
68
+ self.name: str = yaml_data["name"][0].upper() + yaml_data["name"][1:]
69
69
  self.values = values
70
70
  self.value_type = value_type
71
71
 
@@ -146,10 +146,6 @@ class LROOperationBase(OperationBase[LROResponseType]):
146
146
  file_import.add_submodule_import("typing", "cast", ImportType.STDLIB)
147
147
  return file_import
148
148
 
149
- @classmethod
150
- def get_request_builder(cls, yaml_data: Dict[str, Any], client: "Client"):
151
- return client.lookup_request_builder(id(yaml_data["initialOperation"]))
152
-
153
149
 
154
150
  class LROOperation(LROOperationBase[LROResponse]):
155
151
  ...
@@ -57,6 +57,10 @@ class RequestBuilderBase(BaseBuilder[ParameterListType]):
57
57
  self.method: str = yaml_data["method"]
58
58
  self.want_tracing = False
59
59
 
60
+ @property
61
+ def is_lro(self) -> bool:
62
+ return self.yaml_data.get("discriminator") in ("lro", "lropaging")
63
+
60
64
  @property
61
65
  def pylint_disable(self) -> str:
62
66
  if len(self.name) > NAME_LENGTH_LIMIT:
@@ -889,7 +889,6 @@ class _OperationSerializer(
889
889
  self,
890
890
  builder: OperationType,
891
891
  request_builder: RequestBuilderType,
892
- template_url: Optional[str] = None,
893
892
  is_next_request: bool = False,
894
893
  ) -> List[str]:
895
894
  retval: List[str] = []
@@ -949,9 +948,6 @@ class _OperationSerializer(
949
948
  retval.append(
950
949
  f" {body_param.client_name}={body_param.name_in_high_level_operation},"
951
950
  )
952
- if not self.code_model.options["version_tolerant"]:
953
- template_url = template_url or f"self.{builder.name}.metadata['url']"
954
- retval.append(f" template_url={template_url},")
955
951
  retval.append(" headers=_headers,")
956
952
  retval.append(" params=_params,")
957
953
  retval.append(")")
@@ -1011,9 +1007,7 @@ class _OperationSerializer(
1011
1007
  retval.extend(self._create_body_parameter(builder))
1012
1008
  retval.append("")
1013
1009
  retval.extend(
1014
- self._create_request_builder_call(
1015
- builder, request_builder, template_url, is_next_request
1016
- )
1010
+ self._create_request_builder_call(builder, request_builder, is_next_request)
1017
1011
  )
1018
1012
  retval.extend(self._postprocess_http_request(builder, template_url))
1019
1013
  return retval
@@ -1275,11 +1269,6 @@ class _OperationSerializer(
1275
1269
  retval.append("error_map.update(kwargs.pop('error_map', {}) or {})")
1276
1270
  return retval
1277
1271
 
1278
- @staticmethod
1279
- def get_metadata_url(builder: OperationType) -> str:
1280
- url = _escape_str(builder.request_builder.url)
1281
- return f"{builder.name}.metadata = {{'url': {url}}}"
1282
-
1283
1272
  @property
1284
1273
  def _call_method(self) -> str:
1285
1274
  return "await " if self.async_mode else ""
@@ -1326,11 +1315,7 @@ class _PagingOperationSerializer(
1326
1315
  def call_next_link_request_builder(self, builder: PagingOperationType) -> List[str]:
1327
1316
  if builder.next_request_builder:
1328
1317
  request_builder = builder.next_request_builder
1329
- template_url = (
1330
- None
1331
- if self.code_model.options["version_tolerant"]
1332
- else f"'{request_builder.url}'"
1333
- )
1318
+ template_url = None
1334
1319
  else:
1335
1320
  request_builder = builder.request_builder
1336
1321
  template_url = "next_link"
@@ -48,6 +48,7 @@ class OperationGroupsSerializer:
48
48
  and r.group_name == operation_group.property_name
49
49
  and not r.is_overload
50
50
  and not r.abstract
51
+ and not r.is_lro # lro has already initial builder
51
52
  ]
52
53
 
53
54
  def serialize(self) -> str:
@@ -14,6 +14,3 @@
14
14
 
15
15
  {{ op_tools.serialize(operation_serializer.return_lro_poller(operation)) | indent }}
16
16
  {% endif %}
17
- {% if not code_model.options["version_tolerant"] %}
18
- {{ operation_serializer.get_metadata_url(operation) -}}
19
- {% endif %}
@@ -16,6 +16,3 @@
16
16
  {{ op_tools.serialize(operation_serializer.get_long_running_output(operation)) | indent }}
17
17
  {{ op_tools.serialize(operation_serializer.return_lro_poller(operation)) | indent }}
18
18
  {% endif %}
19
- {% if not code_model.options["version_tolerant"] %}
20
- {{ operation_serializer.get_metadata_url(operation) }}
21
- {% endif %}
@@ -0,0 +1,12 @@
1
+ {% macro wrap_model_string(doc_string, wrap_string, suffix_string="") %}
2
+ {% set orignal_result = doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrap_string) %}
3
+ {% set list_result = orignal_result.split('\n') %}
4
+ {% for line in list_result %}
5
+ {% set suffix = suffix_string if list_result | length == loop.index %}
6
+ {% if line | length > 120 %}
7
+ {{ line + " # pylint: disable=line-too-long" }}{{ suffix }}
8
+ {% else %}
9
+ {{ line }}{{ suffix }}
10
+ {% endif %}
11
+ {% endfor %}
12
+ {% endmacro %}
@@ -1,4 +1,5 @@
1
1
  {# actual template starts here #}
2
+ {% import "macros.jinja2" as macros %}
2
3
 
3
4
 
4
5
  {{ serializer.declare_model(model) }}
@@ -20,7 +21,7 @@
20
21
  {% for p in model.properties %}
21
22
  {% for line in serializer.variable_documentation_string(p) %}
22
23
  {% for doc_string in line.replace('\n', '\n ').split('\n') %}
23
- {{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
24
+ {{ macros.wrap_model_string(doc_string, '\n ') -}}
24
25
  {% endfor %}
25
26
  {% endfor %}
26
27
  {% endfor %}
@@ -34,7 +35,7 @@
34
35
  {{ serializer.declare_property(p) }}
35
36
  {% set prop_description = p.description(is_operation_file=False).replace('"', '\\"') %}
36
37
  {% if prop_description %}
37
- """{{ prop_description | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}"""
38
+ """{{ macros.wrap_model_string(prop_description, '\n ', '\"\"\"') -}}
38
39
  {% endif %}
39
40
  {% endfor %}
40
41
 
@@ -1,5 +1,7 @@
1
1
  {# actual template starts here #}
2
-
2
+ {% import "macros.jinja2" as macros %}
3
+ {% set initialize_properties = serializer.initialize_properties(model) %}
4
+ {% set exist_constant = (model.properties | selectattr('constant') | first) is defined %}
3
5
 
4
6
  {{ serializer.declare_model(model) }}
5
7
  """{{ model.description(is_operation_file=False) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
@@ -20,12 +22,13 @@
20
22
  {% for p in model.properties %}
21
23
  {% for line in serializer.variable_documentation_string(p) %}
22
24
  {% for doc_string in line.replace('\n', '\n ').split('\n') %}
23
- {{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
25
+ {{ macros.wrap_model_string(doc_string, '\n ') -}}
24
26
  {% endfor %}
25
27
  {% endfor %}
26
28
  {% endfor %}
27
29
  {% endif %}
28
30
  """
31
+ {% if initialize_properties or exist_constant %}
29
32
  {% if (model.properties | selectattr('validation') ) | first %}
30
33
 
31
34
  _validation = {
@@ -53,7 +56,7 @@
53
56
  {{ model.xml_map_content }}
54
57
  }
55
58
  {% endif %}
56
- {% if (model.properties | selectattr('constant') | first) is defined %}
59
+ {% if exist_constant %}
57
60
 
58
61
  {% for p in model.properties | selectattr('constant')%}
59
62
  {{ p.client_name }} = {{ p.type.get_declaration() }}
@@ -73,7 +76,7 @@
73
76
  {% if p.is_input %}
74
77
  {% for line in serializer.input_documentation_string(p) %}
75
78
  {% for doc_string in line.replace('\n', '\n ').split('\n') %}
76
- {{ doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
79
+ {{ macros.wrap_model_string(doc_string, '\n ') -}}
77
80
  {% endfor %}
78
81
  {% endfor %}
79
82
  {% endif %}
@@ -81,6 +84,7 @@
81
84
  {% endif %}
82
85
  """
83
86
  {{ serializer.super_call(model) }}
84
- {% for initialize_property in serializer.initialize_properties(model) %}
87
+ {% for initialize_property in initialize_properties %}
85
88
  {{ initialize_property }}
86
89
  {% endfor %}
90
+ {% endif %}
@@ -19,6 +19,3 @@
19
19
  {{ op_tools.serialize(operation_serializer.make_pipeline_call(operation)) | indent }}
20
20
  {{ op_tools.serialize(operation_serializer.handle_response(operation)) | indent }}
21
21
  {% endif %}
22
- {% if not code_model.options["version_tolerant"] %}
23
- {{ operation_serializer.get_metadata_url(operation) }}
24
- {% endif %}
@@ -19,6 +19,3 @@
19
19
  get_next, extract_data
20
20
  )
21
21
  {% endif %}
22
- {% if not code_model.options["version_tolerant"] %}
23
- {{ operation_serializer.get_metadata_url(operation) -}}
24
- {% endif %}
@@ -39,6 +39,8 @@ def raise_if_not_implemented(cls, abstract_methods):
39
39
  def quote_etag(etag: Optional[str]) -> Optional[str]:
40
40
  if not etag or etag == "*":
41
41
  return etag
42
+ if etag.startswith("W/"):
43
+ return etag
42
44
  if etag.startswith('"') and etag.endswith('"'):
43
45
  return etag
44
46
  if etag.startswith("'") and etag.endswith("'"):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.7.5",
3
+ "version": "6.7.7",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "main": "index.js",
6
6
  "repository": {