-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normaltopic-import-cycles
Description
Consider this test:
[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.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normaltopic-import-cycles