Skip to content

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

Closed as not planned
@sapetnioc

Description

@sapetnioc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions