From 8c8154aaa05181e39fe70b48bd0dca4455c73597 Mon Sep 17 00:00:00 2001 From: Tim Rid <6593626+timrid@users.noreply.github.com> Date: Fri, 1 Jan 2021 15:41:36 +0100 Subject: [PATCH] satisfy mypy --- construct_typed/tarray.py | 6 +++--- construct_typed/tenum.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/construct_typed/tarray.py b/construct_typed/tarray.py index f0929c8..a413bdf 100644 --- a/construct_typed/tarray.py +++ b/construct_typed/tarray.py @@ -25,14 +25,14 @@ class TArray( super(TArray, self).__init__(cs.Array(count, subcon, discard)) # type: ignore def _decode( - self, obj: ListContainer[ParsedType], context: Context, path: PathType + self, obj: SubconParsedType, context: Context, path: PathType ) -> ParsedType: return list(obj) # type: ignore def _encode( self, - obj: t.Any, + obj: t.List[SubconParsedType], context: Context, path: PathType, - ) -> t.List[t.Any]: + ) -> SubconBuildTypes: return obj # type: ignore diff --git a/construct_typed/tenum.py b/construct_typed/tenum.py index 315bcfe..fd4e33e 100644 --- a/construct_typed/tenum.py +++ b/construct_typed/tenum.py @@ -48,7 +48,7 @@ class TEnum(Adapter[int, int, EnumType, t.Union[int, str, EnumType]]): self.enum_type = enum_type # init adatper - super(TEnum, self).__init__(subcon) # type: ignore + super(TEnum, self).__init__(subcon) def _decode(self, obj: int, context: "cs.Context", path: "cs.PathType") -> EnumType: return self.enum_type(obj) @@ -60,6 +60,7 @@ class TEnum(Adapter[int, int, EnumType, t.Union[int, str, EnumType]]): path: "cs.PathType", ) -> int: try: + # TODO: remove this. only strongly typed enums are allowed... if isinstance(obj, str): return int(self.enum_type[obj]) else: