Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Dec 27, 2024
1 parent 1515219 commit 99a2063
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test-data/unit/check-abstract.test
Original file line number Diff line number Diff line change
Expand Up @@ -1687,3 +1687,24 @@ from typing import TYPE_CHECKING
class C:
if TYPE_CHECKING:
def dynamic(self) -> int: ... # OK

[case testAbstractCallableSubtyping]
import abc
from typing import Callable, Protocol

class Proto(Protocol):
def meth(self): ...

def foo(t: Callable[..., Proto]):
t()

foo(Proto) # E: Argument 1 to "foo" has incompatible type "Type[Proto]"; expected "Callable[..., Proto]"

class Abstract(abc.ABC):
@abc.abstractmethod
def meth(self): ...

def bar(t: Callable[..., Abstract]):
t()

bar(Abstract) # E: Argument 1 to "bar" has incompatible type "Type[Abstract]"; expected "Callable[..., Abstract]"

0 comments on commit 99a2063

Please sign in to comment.