@autorest/python 6.4.12 → 6.4.14
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
|
|
@@ -58,32 +58,35 @@ def _timedelta_as_isostr(td: timedelta) -> str:
|
|
|
58
58
|
if days:
|
|
59
59
|
date_str = "%sD" % days
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
if hours or minutes or seconds:
|
|
62
|
+
# Build time
|
|
63
|
+
time_str = "T"
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
# Hours
|
|
66
|
+
bigger_exists = date_str or hours
|
|
67
|
+
if bigger_exists:
|
|
68
|
+
time_str += "{:02}H".format(hours)
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
# Minutes
|
|
71
|
+
bigger_exists = bigger_exists or minutes
|
|
72
|
+
if bigger_exists:
|
|
73
|
+
time_str += "{:02}M".format(minutes)
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
# Seconds
|
|
76
|
+
try:
|
|
77
|
+
if seconds.is_integer():
|
|
78
|
+
seconds_string = "{:02}".format(int(seconds))
|
|
79
|
+
else:
|
|
80
|
+
# 9 chars long w/ leading 0, 6 digits after decimal
|
|
81
|
+
seconds_string = "%09.6f" % seconds
|
|
82
|
+
# Remove trailing zeros
|
|
83
|
+
seconds_string = seconds_string.rstrip("0")
|
|
84
|
+
except AttributeError: # int.is_integer() raises
|
|
85
|
+
seconds_string = "{:02}".format(seconds)
|
|
85
86
|
|
|
86
|
-
|
|
87
|
+
time_str += "{}S".format(seconds_string)
|
|
88
|
+
else:
|
|
89
|
+
time_str = ""
|
|
87
90
|
|
|
88
91
|
return "P" + date_str + time_str
|
|
89
92
|
|
|
@@ -629,7 +632,7 @@ class _RestField:
|
|
|
629
632
|
self,
|
|
630
633
|
*,
|
|
631
634
|
name: typing.Optional[str] = None,
|
|
632
|
-
type: typing.Optional[typing.Callable] = None,
|
|
635
|
+
type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin
|
|
633
636
|
is_discriminator: bool = False,
|
|
634
637
|
readonly: bool = False,
|
|
635
638
|
default: typing.Any = _UNSET,
|
|
@@ -648,7 +651,7 @@ class _RestField:
|
|
|
648
651
|
raise ValueError("Rest name was never set")
|
|
649
652
|
return self._rest_name_input
|
|
650
653
|
|
|
651
|
-
def __get__(self, obj: Model, type=None):
|
|
654
|
+
def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin
|
|
652
655
|
# by this point, type and rest_name will have a value bc we default
|
|
653
656
|
# them in __new__ of the Model class
|
|
654
657
|
item = obj.get(self._rest_name)
|
|
@@ -677,7 +680,7 @@ class _RestField:
|
|
|
677
680
|
def rest_field(
|
|
678
681
|
*,
|
|
679
682
|
name: typing.Optional[str] = None,
|
|
680
|
-
type: typing.Optional[typing.Callable] = None,
|
|
683
|
+
type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin
|
|
681
684
|
readonly: bool = False,
|
|
682
685
|
default: typing.Any = _UNSET,
|
|
683
686
|
) -> typing.Any:
|
|
@@ -685,6 +688,8 @@ def rest_field(
|
|
|
685
688
|
|
|
686
689
|
|
|
687
690
|
def rest_discriminator(
|
|
688
|
-
*,
|
|
691
|
+
*,
|
|
692
|
+
name: typing.Optional[str] = None,
|
|
693
|
+
type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin
|
|
689
694
|
) -> typing.Any:
|
|
690
695
|
return _RestField(name=name, type=type, is_discriminator=True)
|