Skip to content

False positive for overriding decorated method in an import cycle #5548

Closed

Description

@ilevkivskyi

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.

Activity

  1. 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
  2. added a commit that references this issue on Sep 20, 2018
    b41bb66
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions