Skip to content

unreachable false positive when using isinstance on class with __call__ when function parameter uses ParamSpec #16024

@DetachHead

Description

@DetachHead
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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions