@autorest/python 6.4.13 → 6.4.15
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.
|
@@ -36,6 +36,7 @@ from .parameter import (
|
|
|
36
36
|
)
|
|
37
37
|
from .parameter_list import ParameterList
|
|
38
38
|
from .model_type import ModelType
|
|
39
|
+
from .base import BaseType
|
|
39
40
|
from .request_builder import OverloadedRequestBuilder, RequestBuilder
|
|
40
41
|
|
|
41
42
|
if TYPE_CHECKING:
|
|
@@ -49,6 +50,10 @@ ResponseType = TypeVar(
|
|
|
49
50
|
)
|
|
50
51
|
|
|
51
52
|
|
|
53
|
+
def is_internal(target: Optional[BaseType]) -> bool:
|
|
54
|
+
return isinstance(target, ModelType) and target.base == "dpg" and target.internal
|
|
55
|
+
|
|
56
|
+
|
|
52
57
|
class OperationBase( # pylint: disable=too-many-public-methods
|
|
53
58
|
Generic[ResponseType], BaseBuilder[ParameterList]
|
|
54
59
|
):
|
|
@@ -130,6 +135,13 @@ class OperationBase( # pylint: disable=too-many-public-methods
|
|
|
130
135
|
if self.response_type_annotation(async_mode=False) == "None":
|
|
131
136
|
# doesn't matter if it's async or not
|
|
132
137
|
retval = add_to_pylint_disable(retval, "inconsistent-return-statements")
|
|
138
|
+
try:
|
|
139
|
+
if any(is_internal(r.type) for r in self.responses) or is_internal(
|
|
140
|
+
self.parameters.body_parameter.type
|
|
141
|
+
):
|
|
142
|
+
retval = add_to_pylint_disable(retval, "protected-access")
|
|
143
|
+
except ValueError:
|
|
144
|
+
pass
|
|
133
145
|
return retval
|
|
134
146
|
|
|
135
147
|
def cls_type_annotation(self, *, async_mode: bool) -> str:
|
|
@@ -40,7 +40,11 @@ class RequestBuilderBodyParameter(BodyParameter):
|
|
|
40
40
|
|
|
41
41
|
@property
|
|
42
42
|
def in_method_signature(self) -> bool:
|
|
43
|
-
return
|
|
43
|
+
return (
|
|
44
|
+
super().in_method_signature
|
|
45
|
+
and not self.is_partial_body
|
|
46
|
+
and self.code_model.options["models_mode"] != "dpg"
|
|
47
|
+
)
|
|
44
48
|
|
|
45
49
|
@property
|
|
46
50
|
def method_location(self) -> ParameterMethodLocation:
|
|
@@ -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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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)
|
|
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
|
|