@autorest/python 6.4.12 → 6.4.13
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,28 +30,22 @@ class BlackScriptPlugin(Plugin): # pylint: disable=abstract-method
|
|
|
30
30
|
self.output_folder = Path(output_folder)
|
|
31
31
|
|
|
32
32
|
def process(self) -> bool:
|
|
33
|
-
# apply format_file on every file in the output folder
|
|
33
|
+
# apply format_file on every .py file in the output folder
|
|
34
34
|
list(
|
|
35
35
|
map(
|
|
36
36
|
self.format_file,
|
|
37
|
-
[
|
|
37
|
+
[
|
|
38
|
+
Path(f)
|
|
39
|
+
for f in self.list_file()
|
|
40
|
+
if all(item not in f for item in ("__pycache__", "node_modules"))
|
|
41
|
+
and Path(f).suffix == ".py"
|
|
42
|
+
],
|
|
38
43
|
)
|
|
39
44
|
)
|
|
40
45
|
return True
|
|
41
46
|
|
|
42
47
|
def format_file(self, file: Path) -> None:
|
|
43
|
-
|
|
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":
|
|
53
|
-
self.write_file(file, file_content)
|
|
54
|
-
return
|
|
48
|
+
file_content = self.read_file(file)
|
|
55
49
|
try:
|
|
56
50
|
file_content = black.format_file_contents(
|
|
57
51
|
file_content, fast=True, mode=_BLACK_MODE
|
|
@@ -629,7 +629,7 @@ class _RestField:
|
|
|
629
629
|
self,
|
|
630
630
|
*,
|
|
631
631
|
name: typing.Optional[str] = None,
|
|
632
|
-
type: typing.Optional[typing.Callable] = None,
|
|
632
|
+
type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin
|
|
633
633
|
is_discriminator: bool = False,
|
|
634
634
|
readonly: bool = False,
|
|
635
635
|
default: typing.Any = _UNSET,
|
|
@@ -648,7 +648,7 @@ class _RestField:
|
|
|
648
648
|
raise ValueError("Rest name was never set")
|
|
649
649
|
return self._rest_name_input
|
|
650
650
|
|
|
651
|
-
def __get__(self, obj: Model, type=None):
|
|
651
|
+
def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin
|
|
652
652
|
# by this point, type and rest_name will have a value bc we default
|
|
653
653
|
# them in __new__ of the Model class
|
|
654
654
|
item = obj.get(self._rest_name)
|
|
@@ -677,7 +677,7 @@ class _RestField:
|
|
|
677
677
|
def rest_field(
|
|
678
678
|
*,
|
|
679
679
|
name: typing.Optional[str] = None,
|
|
680
|
-
type: typing.Optional[typing.Callable] = None,
|
|
680
|
+
type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin
|
|
681
681
|
readonly: bool = False,
|
|
682
682
|
default: typing.Any = _UNSET,
|
|
683
683
|
) -> typing.Any:
|
|
@@ -685,6 +685,8 @@ def rest_field(
|
|
|
685
685
|
|
|
686
686
|
|
|
687
687
|
def rest_discriminator(
|
|
688
|
-
*,
|
|
688
|
+
*,
|
|
689
|
+
name: typing.Optional[str] = None,
|
|
690
|
+
type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin
|
|
689
691
|
) -> typing.Any:
|
|
690
692
|
return _RestField(name=name, type=type, is_discriminator=True)
|