File tree 2 files changed +30
-1
lines changed
2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -1600,7 +1600,8 @@ def check_method_override_for_base_with_name(
1600
1600
else :
1601
1601
original_type = NoneType ()
1602
1602
else :
1603
- assert False , str (base_attr .node )
1603
+ # Will always fail to typecheck below, since we know the node is a method
1604
+ original_type = NoneType ()
1604
1605
if isinstance (original_node , (FuncDef , OverloadedFuncDef )):
1605
1606
original_class_or_static = original_node .is_class or original_node .is_static
1606
1607
elif isinstance (original_node , Decorator ):
Original file line number Diff line number Diff line change @@ -7300,3 +7300,31 @@ def identity_wrapper(func: FuncT) -> FuncT:
7300
7300
def foo(self: Any) -> str:
7301
7301
return ""
7302
7302
7303
+ [case testParentClassWithTypeAliasAndSubclassWithMethod]
7304
+ from typing import Any, Callable, TypeVar
7305
+
7306
+ class Parent:
7307
+ foo = Callable[..., int]
7308
+ class bar:
7309
+ pass
7310
+ import typing as baz
7311
+ foobar = TypeVar("foobar")
7312
+
7313
+ class Child(Parent):
7314
+ def foo(self, val: int) -> int: # E: Signature of "foo" incompatible with supertype "Parent"
7315
+ return val
7316
+ def bar(self, val: str) -> str: # E: Signature of "bar" incompatible with supertype "Parent"
7317
+ return val
7318
+ def baz(self, val: float) -> float: # E: Signature of "baz" incompatible with supertype "Parent"
7319
+ return val
7320
+ def foobar(self) -> bool: # E: Signature of "foobar" incompatible with supertype "Parent"
7321
+ return False
7322
+
7323
+ x: Parent.foo = lambda: 5
7324
+ y: Parent.bar = Parent.bar()
7325
+ z: Parent.baz.Any = 1
7326
+ child = Child()
7327
+ a: int = child.foo(1)
7328
+ b: str = child.bar("abc")
7329
+ c: float = child.baz(3.4)
7330
+ d: bool = child.foobar()
You can’t perform that action at this time.
0 commit comments