Skip to content

Commit

Permalink
Casted types to pass pyre check
Browse files Browse the repository at this point in the history
  • Loading branch information
Daquiver1 committed Nov 29, 2023
1 parent 5e39b70 commit 4bdae74
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions projects/jdwp/codegen/dataclass_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def __get_python_type_for(self, struct: Struct, field: Field) -> str:
case Struct():
return self.__struct_to_name[type]
case Array():
return f"typing.List[{self.__struct_to_name[type.element_type]}]"
return f"typing.List[{self.__struct_to_name[typing.cast(Array, type).element_type]}]"
case TaggedUnion():
union_types = [
self.__struct_to_name[case_struct]
for case_struct in type.cases.values()
for case_struct in typing.cast(TaggedUnion, type).cases.values()
]
union_types_str = ", ".join(union_types)
return f"typing.Union[{union_types_str}]"
Expand Down Expand Up @@ -65,9 +65,9 @@ def nested_structs(root: Struct) -> typing.Generator[StructLink, None, None]:
match type:
case Array():
yield root, field, type.element_type
yield from nested_structs(type.element_type)
yield from nested_structs(typing.cast(Array, type).element_type)
case TaggedUnion():
for struct in type.cases.values():
for struct in typing.cast(TaggedUnion, type).cases.values():
yield root, field, struct
yield from nested_structs(struct)
case Struct():
Expand Down

0 comments on commit 4bdae74

Please sign in to comment.