Open
Description
The overloaded version has different behavior to the normal version. because it is returning NoReturn
it should silence the 'unreachable' error.
from typing import overload, NoReturn
@overload
def f(a: str) -> int: ...
@overload
def f(a: str, b: NoReturn) -> NoReturn: ...
def f(a: str, b: NoReturn = ...) -> object: ...
b: bool
assert b
if not b:
f("") # error: Statement is unreachable ✅
print("hi")
if not b:
f("", b) # error: Statement is unreachable ❌
print("hi")
def f2(a: str, b: NoReturn) -> NoReturn: ...
if not b:
f2("", b) # no error ✅
print("hi")
> Test run complete: 2 passed, 1 failed <
Failures:
---------------------------
if not b:
f("", b) # error: Statement is unreachable ❌
print("hi")
---------------------------
Expected:
no error ✅
Actual:
error: Statement is unreachable ❌