Skip to content

Commit

Permalink
Fix clashing UnionTypeDef name assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
vemel committed Apr 24, 2024
1 parent 2b1717c commit b8c05b0
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions mypy_boto3_builder/parsers/shape_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def parse_shape(
Returns:
TypeAnnotation or similar class.
"""
if "eventstream" in shape.serialization and shape.serialization["eventstream"]:
if shape.serialization.get("eventstream"):
shape.serialization["eventstream"] = False
return TypeSubscript(
ExternalImport.from_class(EventStream),
Expand Down Expand Up @@ -552,26 +552,26 @@ def parse_shape(
if shape_type_stub:
return shape_type_stub

if isinstance(shape, StringShape):
return self._parse_shape_string(shape, output_child=is_output_or_child)

if isinstance(shape, MapShape):
return self._parse_shape_map(
shape,
output_child=is_output_or_child,
is_streaming=is_streaming,
)

if isinstance(shape, StructureShape):
return self._parse_shape_structure(
shape,
output=output,
output_child=is_output_or_child,
is_streaming=is_streaming,
)

if isinstance(shape, ListShape):
return self._parse_shape_list(shape, output_child=is_output_or_child)
match shape:
case StringShape():
return self._parse_shape_string(shape, output_child=is_output_or_child)
case MapShape():
return self._parse_shape_map(
shape,
output_child=is_output_or_child,
is_streaming=is_streaming,
)
case StructureShape():
return self._parse_shape_structure(
shape,
output=output,
output_child=is_output_or_child,
is_streaming=is_streaming,
)
case ListShape():
return self._parse_shape_list(shape, output_child=is_output_or_child)
case _:
pass

if shape.type_name in self._get_resource_names():
return InternalImport(shape.type_name, use_alias=True)
Expand Down Expand Up @@ -1038,8 +1038,8 @@ def fix_method_arguments_for_mypy(self, methods: Sequence[Method]) -> None:
f"Adding output shape to {method.name} {argument.name} type:"
f" {input_typed_dict.name} | {output_typed_dict.name}"
)
union_name = get_type_def_name(
self._get_typed_dict_name_prefix(input_typed_dict.name), "Union"
union_name = self._get_non_clashing_typed_dict_name(
input_typed_dict, "Union"
)
argument.type_annotation = TypeUnion(
name=union_name,
Expand All @@ -1055,8 +1055,8 @@ def fix_method_arguments_for_mypy(self, methods: Sequence[Method]) -> None:
f"Adding output shape to {method.name} {argument.name} type:"
f" {input_typed_dict.name} | {output_typed_dict.name}"
)
union_name = get_type_def_name(
self._get_typed_dict_name_prefix(input_typed_dict.name), "Union"
union_name = self._get_non_clashing_typed_dict_name(
input_typed_dict, "Union"
)
parent.replace_child(
input_typed_dict,
Expand Down

0 comments on commit b8c05b0

Please sign in to comment.