Another fix for mypy 1.12
This commit is contained in:
parent
46c610525c
commit
a81fd3b1c2
1 changed files with 4 additions and 3 deletions
|
|
@ -2,6 +2,7 @@
|
|||
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import errno
|
||||
import inspect
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
|
|
@ -287,7 +288,7 @@ def asdict(self, keep_defaults: bool = False) -> dict[str, Union[str, int, bytes
|
|||
val = getattr(self, k.name)
|
||||
if not keep_defaults and val == k.default:
|
||||
continue
|
||||
if issubclass(k.type, Enum):
|
||||
if inspect.isclass(k.type) and issubclass(k.type, Enum):
|
||||
val = val.name
|
||||
ans[k.name] = val
|
||||
return ans
|
||||
|
|
@ -310,7 +311,7 @@ def get_serialized_fields(self, prefix_with_osc_code: bool = False) -> Iterator[
|
|||
found = True
|
||||
yield nts[name]
|
||||
yield '='
|
||||
if issubclass(k.type, Enum):
|
||||
if inspect.isclass(k.type) and issubclass(k.type, Enum):
|
||||
yield val.name
|
||||
elif k.type is bytes:
|
||||
yield base64_encode(val)
|
||||
|
|
@ -337,7 +338,7 @@ def handle_item(key: memoryview, val: memoryview) -> None:
|
|||
field = fmap.get(key)
|
||||
if field is None:
|
||||
return
|
||||
if issubclass(field.type, Enum):
|
||||
if inspect.isclass(field.type) and issubclass(field.type, Enum):
|
||||
setattr(ans, field.name, field.type[str(val, "utf-8")])
|
||||
elif field.type is bytes:
|
||||
setattr(ans, field.name, base64_decode(val))
|
||||
|
|
|
|||
Loading…
Reference in a new issue