Skip to content

Commit

Permalink
Simplify _parse_shape_map
Browse files Browse the repository at this point in the history
  • Loading branch information
vemel committed Dec 21, 2024
1 parent 28b3fcb commit 1f7e1a3
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions mypy_boto3_builder/parsers/shape_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,30 +407,26 @@ def _parse_shape_map(
is_output_child: bool = False,
is_streaming: bool = False,
) -> FakeAnnotation:
type_subscript = (
TypeSubscript(Type.dict) if is_output_child else TypeSubscript(Type.Mapping)
)
if shape.key:
type_subscript.add_child(
self.parse_shape(
shape.key,
is_output_child=is_output_child,
is_streaming=is_streaming,
),
parent = Type.dict if is_output_child else Type.Mapping
key_child = (
self.parse_shape(
shape.key,
is_output_child=is_output_child,
is_streaming=is_streaming,
)
else:
type_subscript.add_child(Type.str)
if shape.value:
type_subscript.add_child(
self.parse_shape(
shape.value,
is_output_child=is_output_child,
is_streaming=is_streaming,
),
if shape.key
else Type.str
)
value_child = (
self.parse_shape(
shape.value,
is_output_child=is_output_child,
is_streaming=is_streaming,
)
else:
type_subscript.add_child(Type.Any)
return type_subscript
if shape.value
else Type.Any
)
return TypeSubscript(parent, [key_child, value_child])

def _get_typed_dict_map(self, *, output: bool, output_child: bool) -> TypedDictMap:
if output:
Expand Down

0 comments on commit 1f7e1a3

Please sign in to comment.