@autorest/python 6.2.7 → 6.2.9

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.
@@ -30,7 +30,11 @@ class ListType(BaseType):
30
30
  return f"[{self.element_type.serialization_type}]"
31
31
 
32
32
  def type_annotation(self, **kwargs: Any) -> str:
33
- if self.code_model.options["version_tolerant"] and self.element_type.is_xml:
33
+ if (
34
+ self.code_model.options["version_tolerant"]
35
+ and self.element_type.is_xml
36
+ and not self.code_model.options["models_mode"]
37
+ ):
34
38
  # this means we're version tolerant XML, we just return the XML element
35
39
  return self.element_type.type_annotation(**kwargs)
36
40
  return f"List[{self.element_type.type_annotation(**kwargs)}]"
@@ -140,7 +144,9 @@ class ListType(BaseType):
140
144
  def imports(self, **kwargs: Any) -> FileImport:
141
145
  file_import = FileImport()
142
146
  if not (
143
- self.code_model.options["version_tolerant"] and self.element_type.is_xml
147
+ self.code_model.options["version_tolerant"]
148
+ and self.element_type.is_xml
149
+ and not self.code_model.options["models_mode"]
144
150
  ):
145
151
  file_import.add_submodule_import(
146
152
  "typing", "List", ImportType.STDLIB, TypingSection.CONDITIONAL
@@ -142,7 +142,7 @@ class JinjaSerializer(ReaderAndWriter): # pylint: disable=abstract-method
142
142
  namespace_path = (
143
143
  Path(".")
144
144
  if self.code_model.options["no_namespace_folders"]
145
- else Path(*(self.code_model.namespace.split(".")))
145
+ else Path(*self._name_space().split("."))
146
146
  )
147
147
 
148
148
  p = namespace_path.parent
@@ -532,9 +532,17 @@ class JinjaSerializer(ReaderAndWriter): # pylint: disable=abstract-method
532
532
  namespace_path / Path("_metadata.json"), metadata_serializer.serialize()
533
533
  )
534
534
 
535
+ def _name_space(self) -> str:
536
+ if self.code_model.namespace.count(".") >= (
537
+ self.code_model.options["package_name"] or ""
538
+ ).count("-"):
539
+ return self.code_model.namespace
540
+
541
+ return self.code_model.options["package_name"].replace("-", ".")
542
+
535
543
  # find root folder where "setup.py" is
536
544
  def _package_root_folder(self, namespace_path: Path) -> Path:
537
- return namespace_path / Path("../" * (self.code_model.namespace.count(".") + 1))
545
+ return namespace_path / Path("../" * (self._name_space().count(".") + 1))
538
546
 
539
547
  def _serialize_and_write_sample(self, env: Environment, namespace_path: Path):
540
548
  out_path = self._package_root_folder(namespace_path) / Path("generated_samples")
@@ -257,7 +257,6 @@ def _get_model(module_name: str, model_name: str):
257
257
  module = sys.modules[module_end]
258
258
  models = {k: v for k, v in module.__dict__.items() if isinstance(v, type)}
259
259
  if model_name not in models:
260
- _LOGGER.warning("Can not find model name in models, will not deserialize")
261
260
  return model_name
262
261
  return models[model_name]
263
262
 
@@ -491,7 +490,7 @@ def _get_deserialize_callable_from_annotation(
491
490
  pass
492
491
  raise DeserializationError()
493
492
  return functools.partial(_deserialize_with_union, annotation)
494
-
493
+
495
494
  # is it optional?
496
495
  try:
497
496
  # right now, assuming we don't have unions, since we're getting rid of the only
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  {{ serializer.declare_model(model) }}
5
- """{{ model.description(is_operation_file=False) }}
5
+ """{{ model.description(is_operation_file=False) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
6
6
  {% if model.discriminated_subtypes %}
7
7
 
8
8
  {{ serializer.discriminator_docstring(model) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  {{ serializer.declare_model(model) }}
5
- """{{ model.description(is_operation_file=False) }}
5
+ """{{ model.description(is_operation_file=False) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
6
6
  {% if model.discriminated_subtypes %}
7
7
 
8
8
  {{ serializer.discriminator_docstring(model) | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n ') }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.2.7",
3
+ "version": "6.2.9",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "repository": {
6
6
  "type": "git",