@azure-tools/typespec-python 0.31.0 → 0.31.1
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.
- package/generator/pygen/codegen/serializers/builder_serializer.py +3 -1
- package/generator/pygen/codegen/serializers/model_serializer.py +11 -4
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +1 -1
- package/generator/pygen/codegen/templates/model_dpg.py.jinja2 +1 -1
- package/package.json +1 -1
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
|
@@ -1089,7 +1089,9 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1089
1089
|
return retval
|
|
1090
1090
|
|
|
1091
1091
|
def error_map(self, builder: OperationType) -> List[str]:
|
|
1092
|
-
retval = [
|
|
1092
|
+
retval = [
|
|
1093
|
+
"error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object"
|
|
1094
|
+
]
|
|
1093
1095
|
if builder.non_default_errors:
|
|
1094
1096
|
if not 401 in builder.non_default_error_status_codes:
|
|
1095
1097
|
retval.append(" 401: ClientAuthenticationError,")
|
|
@@ -255,11 +255,18 @@ class DpgModelSerializer(_ModelSerializer):
|
|
|
255
255
|
args.append(f"xml={prop.xml_metadata}")
|
|
256
256
|
|
|
257
257
|
field = "rest_discriminator" if prop.is_discriminator else "rest_field"
|
|
258
|
-
type_ignore =
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
type_ignore = (
|
|
259
|
+
" # type: ignore"
|
|
260
|
+
if prop.is_discriminator and isinstance(prop.type, (ConstantType, EnumValue)) and prop.type.value
|
|
261
|
+
else ""
|
|
262
|
+
)
|
|
263
|
+
generated_code = f'{prop.client_name}: {prop.type_annotation()} = {field}({", ".join(args)})'
|
|
264
|
+
pylint_disable = (
|
|
265
|
+
" # pylint: disable=line-too-long"
|
|
266
|
+
if len(generated_code) <= 120 < (len(generated_code) + len(type_ignore))
|
|
267
|
+
else ""
|
|
262
268
|
)
|
|
269
|
+
return f"{generated_code}{type_ignore}{pylint_disable}"
|
|
263
270
|
|
|
264
271
|
def initialize_properties(self, model: ModelType) -> List[str]:
|
|
265
272
|
init_args = []
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
{% set need_init = (not model.internal) and (serializer.init_line(model) or model.discriminator)%}
|
|
54
54
|
{% if need_init %}
|
|
55
55
|
@overload
|
|
56
|
-
def __init__(
|
|
56
|
+
def __init__({{ model.init_pylint_disable }}
|
|
57
57
|
self,
|
|
58
58
|
{% for param_signature in serializer.init_line(model) %}
|
|
59
59
|
{{ param_signature }}
|
package/package.json
CHANGED
|
Binary file
|