Closed as not planned
Description
Bug Report
If you have a method that has an overload for specific arguments that are not allowed, by having that overload return NoReturn
, and a wider default that accepts Any
, mypy does not detect the invalid argument.
To Reproduce
from typing import Any, NoReturn, overload
class Goo:
@overload
def __add__(self, other: str) -> NoReturn:
...
@overload
def __add__(self, other: Any) -> bool:
...
def __add__(self, other: Any) -> bool:
return True
y = Goo()
y + 4
y + "abc"
Expected Behavior
I expect that the line y + "abc"
is reported as an invalid operation.
Actual Behavior
Success: no issues found in 1 source file
Your Environment
- Mypy version used: 1.4.1
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.9.16