@autorest/python 6.3.2 → 6.4.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.
@@ -13,7 +13,7 @@ from black.report import NothingChanged
13
13
  from .. import Plugin, PluginAutorest
14
14
  from .._utils import parse_args
15
15
 
16
- logging.getLogger("blib2to3").setLevel(logging.ERROR)
16
+ _LOGGER = logging.getLogger("blib2to3")
17
17
 
18
18
  _BLACK_MODE = black.Mode() # pyright: ignore [reportPrivateImportUsage]
19
19
  _BLACK_MODE.line_length = 120
@@ -40,8 +40,16 @@ class BlackScriptPlugin(Plugin): # pylint: disable=abstract-method
40
40
  return True
41
41
 
42
42
  def format_file(self, file: Path) -> None:
43
- file_content = self.read_file(file)
44
- if not file.suffix == ".py":
43
+ try:
44
+ file_content = self.read_file(file)
45
+ except Exception as e: # pylint: disable=broad-except
46
+ if file.suffix != ".py":
47
+ _LOGGER.warning(
48
+ "Can not read file %s, not blacking this file", file.name
49
+ )
50
+ return
51
+ raise e # still want to raise if we fail reading a py file
52
+ if file.suffix != ".py":
45
53
  self.write_file(file, file_content)
46
54
  return
47
55
  try:
@@ -164,6 +164,7 @@ class CodeGenerator(Plugin):
164
164
  low_level_client or version_tolerant,
165
165
  ),
166
166
  "generate_sample": self.options.get("generate-sample", False),
167
+ "default_api_version": self.options.get("default-api-version"),
167
168
  }
168
169
 
169
170
  if options["builders_visibility"] is None:
@@ -276,6 +277,7 @@ class CodeGeneratorAutorest(CodeGenerator, PluginAutorest):
276
277
  "default-optional-constants-to-none"
277
278
  ),
278
279
  "generate-sample": self._autorestapi.get_boolean_value("generate-sample"),
280
+ "default-api-version": self._autorestapi.get_value("default-api-version"),
279
281
  }
280
282
  return {k: v for k, v in options.items() if v is not None}
281
283
 
@@ -125,7 +125,6 @@ class JinjaSerializer(ReaderAndWriter): # pylint: disable=abstract-method
125
125
  self.code_model.options["show_operations"]
126
126
  and self.code_model.has_operations
127
127
  and self.code_model.options["generate_sample"]
128
- and not self.code_model.options["multiapi"]
129
128
  ):
130
129
  self._serialize_and_write_sample(env, namespace_path)
131
130
 
@@ -549,6 +548,12 @@ class JinjaSerializer(ReaderAndWriter): # pylint: disable=abstract-method
549
548
  for client in self.code_model.clients:
550
549
  for op_group in client.operation_groups:
551
550
  for operation in op_group.operations:
551
+ if (
552
+ self.code_model.options["multiapi"]
553
+ and operation.api_versions[0]
554
+ != self.code_model.options["default_api_version"]
555
+ ):
556
+ continue
552
557
  samples = operation.yaml_data["samples"]
553
558
  if not samples or operation.name.startswith("_"):
554
559
  continue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.3.2",
3
+ "version": "6.4.0",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "main": "index.js",
6
6
  "repository": {
package/requirements.txt CHANGED
@@ -6,7 +6,7 @@ json-rpc==1.14.0
6
6
  m2r2==0.3.3
7
7
  MarkupSafe==2.1.2
8
8
  mistune==0.8.4
9
- pathspec==0.10.3
9
+ pathspec==0.11.0
10
10
  platformdirs==2.6.2
11
11
  PyYAML==6.0
12
12
  tomli==2.0.1