@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.
@@ -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 = ["error_map: MutableMapping[int, Type[HttpResponseError]] = {"]
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 = prop.is_discriminator and isinstance(prop.type, (ConstantType, EnumValue)) and prop.type.value
259
- return (
260
- f"{prop.client_name}: {prop.type_annotation()} ="
261
- f' {field}({", ".join(args)}){" # type: ignore" if type_ignore else ""}'
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 = []
@@ -1130,7 +1130,7 @@ def _deserialize_xml(
1130
1130
  deserializer: typing.Any,
1131
1131
  value: str,
1132
1132
  ) -> typing.Any:
1133
- element = ET.fromstring(value)
1133
+ element = ET.fromstring(value) # nosec
1134
1134
  return _deserialize(deserializer, element)
1135
1135
 
1136
1136
 
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-python",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec emitter for Python SDKs",
6
6
  "homepage": "https://github.com/Azure/autorest.python",