Skip to content

Implement PEP 604 rewrites for isinstance and issubclass checks #2923

@michaeloliverx

Description

@michaeloliverx

PEP 604 introduced simplified syntax for union types e.g. var: str | int for which we already have support for in #369. It also allows this syntax to be used inside isinstance and issubclass checks, it would be great if these could be autofixed too!

# before
isinstance("", (int, str))
# after
isinstance("", int | str)


# before
issubclass(bool, (int, float))
# after
issubclass(bool, int | float)

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixesRelated to suggested fixes for violationsruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions