Skip to content

Commit

Permalink
Fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Jul 6, 2023
1 parent 5575d58 commit eba576d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions fido2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
Any,
TypeVar,
Hashable,
ClassVar,
Dict,
get_type_hints,
)
import struct
Expand Down Expand Up @@ -208,11 +206,12 @@ def _parse_value(t, value):


class _DataClassMapping(Mapping[_T, Any]):
__dataclass_fields__: ClassVar[Dict[str, Field[Any]]]
# TODO: This requires Python 3.9, and fixes the tpye errors we now ignore
# __dataclass_fields__: ClassVar[Dict[str, Field[Any]]]

def __post_init__(self):
hints = get_type_hints(type(self))
for f in fields(self):
for f in fields(self): # type: ignore
value = getattr(self, f.name)
if value is None:
continue
Expand All @@ -230,7 +229,7 @@ def _get_field_key(cls, field: Field) -> _T:
raise NotImplementedError()

def __getitem__(self, key):
for f in fields(self):
for f in fields(self): # type: ignore
if key == self._get_field_key(f):
value = getattr(self, f.name)
serialize = f.metadata.get("serialize")
Expand All @@ -248,7 +247,7 @@ def __getitem__(self, key):
def __iter__(self):
return (
self._get_field_key(f)
for f in fields(self)
for f in fields(self) # type: ignore
if getattr(self, f.name) is not None
)

Expand All @@ -268,7 +267,7 @@ def from_dict(cls, data: Optional[Mapping[_T, Any]]):
)

kwargs = {}
for f in fields(cls):
for f in fields(cls): # type: ignore
key = cls._get_field_key(f)
if key in data:
value = data[key]
Expand Down

0 comments on commit eba576d

Please sign in to comment.