Message402914
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. |
|
Date |
User |
Action |
Args |
2021-09-29 21:14:09 | AMDmi3 | set | recipients:
+ AMDmi3 |
2021-09-29 21:14:09 | AMDmi3 | set | messageid: <1632950049.79.0.711339156878.issue45326@roundup.psfhosted.org> |
2021-09-29 21:14:09 | AMDmi3 | link | issue45326 messages |
2021-09-29 21:14:09 | AMDmi3 | create | |
|