diff --git a/construct_typed/tenum.py b/construct_typed/tenum.py index 300654c..d9454c8 100644 --- a/construct_typed/tenum.py +++ b/construct_typed/tenum.py @@ -48,13 +48,13 @@ class TEnum(Adapter[int, int, EnumType, EnumType]): ) # save enum type - self.enum_type = enum_type + self.enum_type = t.cast(t.Type[EnumType], enum_type) # type: ignore # init adatper super(TEnum, self).__init__(subcon) def _decode(self, obj: int, context: Context, path: PathType) -> EnumType: - return self.enum_type(obj) # type: ignore + return self.enum_type(obj) def _encode( self, @@ -86,13 +86,13 @@ class TFlagsEnum(Adapter[int, int, FlagsEnumType, FlagsEnumType]): ) # save enum type - self.enum_type = enum_type + self.enum_type = t.cast(t.Type[FlagsEnumType], enum_type) # type: ignore # init adatper super(TFlagsEnum, self).__init__(subcon) def _decode(self, obj: int, context: Context, path: PathType) -> FlagsEnumType: - return self.enum_type(obj) # type: ignore + return self.enum_type(obj) def _encode( self, diff --git a/requirements.txt b/requirements.txt index 1048144..e7dc9eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ construct==2.10.* pytest>=6.2.0 numpy==1.19.3 arrow -ruamel.yaml \ No newline at end of file +ruamel.yaml +mypy \ No newline at end of file diff --git a/tests/test_typed.py b/tests/test_typed.py index 770b418..783015e 100644 --- a/tests/test_typed.py +++ b/tests/test_typed.py @@ -11,7 +11,7 @@ import pytest from .declarativeunittest import common, raises, setattrs -def test_tcontainer_compare_with_dataclass(): +def test_tcontainer_compare_with_dataclass() -> None: @dataclasses.dataclass class TestContainer: a: t.Optional[int] = cst.TStructField(cs.Const(1, cs.Byte))