Bug Report
mypy 0.981 and 0.982 consider Hashable and None to be overlapping.
I know that technically it is correct, since None is indeed hashable, but the way that None is used in python for default values makes this overlap inconvenient.
I could not find any hint in the changelog that indicates that this has changed.
To Reproduce
from typing import Hashable
@overload
def x(a: Hashable) -> Hashable: ...
@overload
def x(a: None = None) -> None: ...
def x(a: Hashable | None = None) -> Hashable | None:
return a
Expected Behavior
Like mypy <= 0.971 no issue here.
Actual Behavior
error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
Other
In case the new behavior is intended, is there a way to specify a "hashable but not None" type?
Your Environment
- Mypy version used: 0.981 (and 0.982, 0.971 to compare)
- Mypy command-line flags: /
- Mypy configuration options from
mypy.ini (and other config files): show_error_codes = True
- Python version used: 3.9.7
Bug Report
mypy 0.981 and 0.982 consider
HashableandNoneto be overlapping.I know that technically it is correct, since
Noneis indeed hashable, but the way thatNoneis used in python for default values makes this overlap inconvenient.I could not find any hint in the changelog that indicates that this has changed.
To Reproduce
Expected Behavior
Like mypy <= 0.971 no issue here.
Actual Behavior
Other
In case the new behavior is intended, is there a way to specify a "hashable but not None" type?
Your Environment
mypy.ini(and other config files): show_error_codes = True