Open DetachHead opened 1 year ago
from typing import Callable, ParamSpec P = ParamSpec("P") class Foo: def __call__(self) -> None: ... def foo(fn: Callable[P, None]) -> None: if isinstance(fn, Foo): print("reached") # error: Statement is unreachable [unreachable] foo(Foo())
playground
in this example, that line is always reached at runtime
minified further:
from typing import Callable def foo(fn: Callable[[], object]) -> None: if isinstance(fn, type): print(fn)
playground
in this example, that line is always reached at runtime