New submission from Dmitry Marakasov <[email protected]>:
Here's a curious problem. issubclass() check of a type against an ABC-derived
class raises TypeError claiming that type is not a class, however
inspect.isclass() says it's a class, and issubclass() check against a simple
class works fine:
```
from abc import ABC
class C1:
pass
issubclass(dict[str, str], C1) # False
class C2(ABC):
pass
issubclass(dict[str, str], C2) # TypeError: issubclass() arg 1 must be a class
```
I've ran into this problem while using `inspect` module to look for subclasses
of a specific ABC in a module which may also contain type aliases, and after
converting a type alias from `Dict[str, str]` to modern `dict[str, str]` I've
got an unexpected crash in this code:
if inspect.isclass(member) and issubclass(member, superclass):
Not sure which is the culprit, ABC or how dict[]-style type aliases are
implemented.
----------
components: Library (Lib)
messages: 402914
nosy: AMDmi3
priority: normal
severity: normal
status: open
title: Unexpected TypeError with type alias+issubclass+ABC
versions: Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45326>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com