Skip to content

is_subtype vs is_proper_subtype #3297

Closed
@ilevkivskyi

Description

@ilevkivskyi

Currently, we have two functions is_subtype and is_proper_subtype. There are two corresponding visitors: SubtypeVisitor and ProperSubtypeVisitor, both of them implement some complex logic.
I think that ideally there should be only one visitor, ProperSubtypeVisitor, and is_subtype should be simply:

def is_subtype(left, right):
    if isinstance(left, AnyType) or isinstance(right, AnyType):
        return True
    return is_proper_subtype(left, right)

Are there any reasons why it is not possible now? Maybe this question already exists in a roadmap mentioned in #3194 (btw @JukkaL @ddfisher is it possible to make it public?)

(I have found this issue #2038, but I am not sure it is up to date.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactoringChanging mypy's internals

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions