Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isinstance(list[anything], type) returns False since Python 3.11 #117316

Closed
sapetnioc opened this issue Mar 28, 2024 · 1 comment
Closed

isinstance(list[anything], type) returns False since Python 3.11 #117316

sapetnioc opened this issue Mar 28, 2024 · 1 comment
Labels
topic-typing type-bug An unexpected behavior, bug, or error

Comments

@sapetnioc
Copy link

sapetnioc commented Mar 28, 2024

Bug report

Bug description:

Types with subclasses such as list[...] or dict[...] are not considered to be instance of type by isinstance() whereas standard types (list, dict, ...) are. This difference is surprising if we consider, for instance, that list is in the __mro__ of list[int]. I suspect that this inconsistency is a bug.

CPython versions tested on:

3.9, 3.10, 3.11, 3.12

Operating systems tested on:

Linux

@sapetnioc sapetnioc added the type-bug An unexpected behavior, bug, or error label Mar 28, 2024
@AlexWaygood
Copy link
Member

This was a deliberate change made due to a large number of issues that the previous behaviour caused. See #89828. I don't think we'll be changing this behaviour again.

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-typing type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants