[New-bugs-announce] [issue44293] PEP 585 breaks inspect.isclass

Joseph Perez report at bugs.python.org
Wed Jun 2 18:26:01 EDT 2021


New submission from Joseph Perez <joperez at hotmail.fr>:

PEP 585 has the side-effect of making `list[int]` an instance of `type`. This is not the case for other generic aliases.

It also implies that `inspect.isclass(list[int]) is True`, while `list[int]` is not a class; as a proof of this statement `issubclass(list[int], collections.abc.Collection)` raises `TypeError: issubclass() arg 1 must be a class`.

By the way, there is the awkward thing of having `isinstance(list[int], type) is True` while `issubclass(type(list[int]), type) is False`.

----------
messages: 394950
nosy: joperez
priority: normal
severity: normal
status: open
title: PEP 585 breaks inspect.isclass
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44293>
_______________________________________


More information about the New-bugs-announce mailing list