Skip to content

None is not considered Hashable #8768

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

Closed
NeilGirdhar opened this issue May 3, 2020 · 1 comment · Fixed by #9371
Closed

None is not considered Hashable #8768

NeilGirdhar opened this issue May 3, 2020 · 1 comment · Fixed by #9371
Assignees
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high

Comments

@NeilGirdhar
Copy link
Contributor

NeilGirdhar commented May 3, 2020

from typing import Hashable


def f() -> Hashable:
    return None


print(isinstance(None, Hashable))

The print returns True, so Python understands that None is hashable, but MyPy complains about incompatible return types:

error: Incompatible return value type (got "None", expected "Hashable")
@JukkaL
Copy link
Collaborator

JukkaL commented Aug 28, 2020

Marking as high priority since typeshed is getting new Hashable type annotations, and these can cause false positives when updating to a more recent mypy release.

@JukkaL JukkaL self-assigned this Aug 28, 2020
JukkaL added a commit that referenced this issue Aug 28, 2020
JukkaL added a commit that referenced this issue Aug 28, 2020
JukkaL added a commit that referenced this issue Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants