This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author AMDmi3
Recipients AMDmi3
Date 2021-09-29.21:14:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632950049.79.0.711339156878.issue45326@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-09-29 21:14:09AMDmi3setrecipients: + AMDmi3
2021-09-29 21:14:09AMDmi3setmessageid: <1632950049.79.0.711339156878.issue45326@roundup.psfhosted.org>
2021-09-29 21:14:09AMDmi3linkissue45326 messages
2021-09-29 21:14:09AMDmi3create