From 4bdae74bc89af04310ebafb37491e1e15531760c Mon Sep 17 00:00:00 2001 From: Christian Abrokwa Date: Wed, 29 Nov 2023 15:49:57 +0000 Subject: [PATCH] Casted types to pass pyre check --- projects/jdwp/codegen/dataclass_generator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/jdwp/codegen/dataclass_generator.py b/projects/jdwp/codegen/dataclass_generator.py index 7bf0d1b..caca420 100644 --- a/projects/jdwp/codegen/dataclass_generator.py +++ b/projects/jdwp/codegen/dataclass_generator.py @@ -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}]" @@ -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():