You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive for overriding decorated method in an import cycle #5548
[case testCyclicDecoratir]
import b
[file a.py]
import b
import c
class A(b.B):
@c.deco
def meth(self) -> int: ...
[file b.py]
import a
import c
class B:
@c.deco
def meth(self) -> int: ...
[file c.py]
from typing import TypeVar, Tuple, Callable
T = TypeVar('T')
def deco(f: Callable[..., T]) -> Callable[..., Tuple[T, int]]: ...
[out]
It currently fails with
tmp/a.py:6: error: Signature of "meth" incompatible with supertype "B"
Although it is obviously compatible (it is actually identical). The error goes away if I change the order files are processed in the cycle (by importing a in main).
The reason is that non-trivial decorator needs to be type-checked to find the type in superclass first. A potential solution is to just defer the subclass method node.
changed the title [-]False negative for overriding decorated method in an import cycle[/-][+]False positive for overriding decorated method in an import cycle[/+]on Aug 31, 2018
Activity
[-]False negative for overriding decorated method in an import cycle[/-][+]False positive for overriding decorated method in an import cycle[/+]Defer subclass methods if superclass has not been analyzed (#5637)