Skip to content

Commit 92e750e

Browse files
committed
Add testcase checking superclass compat
1 parent 1042e69 commit 92e750e

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

test-data/unit/check-classes.test

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6651,7 +6651,51 @@ from typing import TypeVar, Tuple, Callable
66516651
T = TypeVar('T')
66526652
def deco(f: Callable[..., T]) -> Callable[..., Tuple[T, int]]: ...
66536653
[builtins fixtures/tuple.pyi]
6654-
[out]
6654+
6655+
[case testOverrideWithUntypedNotChecked]
6656+
class Parent:
6657+
def foo(self, x):
6658+
...
6659+
def bar(self, x):
6660+
...
6661+
def baz(self, x: int) -> str:
6662+
return ""
6663+
6664+
class Child(Parent):
6665+
def foo(self, y): # OK: names not checked
6666+
...
6667+
def bar(self, x, y):
6668+
...
6669+
def baz(self, x, y):
6670+
return ""
6671+
[builtins fixtures/tuple.pyi]
6672+
6673+
[case testOverrideWithUntypedCheckedWithCheckUntypedDefs]
6674+
# flags: --check-untyped-defs
6675+
class Parent:
6676+
def foo(self, x):
6677+
...
6678+
def bar(self, x):
6679+
...
6680+
def baz(self, x: int) -> str:
6681+
return ""
6682+
6683+
class Child(Parent):
6684+
def foo(self, y): # OK: names not checked
6685+
...
6686+
def bar(self, x, y) -> None: # E: Signature of "bar" incompatible with supertype "Parent" \
6687+
# N: Superclass: \
6688+
# N: def bar(self, x: Any) -> Any \
6689+
# N: Subclass: \
6690+
# N: def bar(self, x: Any, y: Any) -> None
6691+
...
6692+
def baz(self, x, y): # E: Signature of "baz" incompatible with supertype "Parent" \
6693+
# N: Superclass: \
6694+
# N: def baz(self, x: int) -> str \
6695+
# N: Subclass: \
6696+
# N: def baz(self, x: Any, y: Any) -> Any
6697+
return ""
6698+
[builtins fixtures/tuple.pyi]
66556699

66566700
[case testOptionalDescriptorsBinder]
66576701
from typing import Type, TypeVar, Optional

0 commit comments

Comments
 (0)