Skip to content

Inheritance from dataclass across modules deduces wrong __init__ #628

@MatthiasThul

Description

@MatthiasThul

Consider the following example:

a.py:

from dataclasses import dataclass

@dataclass
class A:
    a: int

b.py:

from a import A
from dataclasses import dataclass

@dataclass
class B(A):
    pass

b = B(1)

This should be valid but Pytype 2020.07.24 gives:

File "b.py", line 9, in <module>: Function B.__init__ expects 1 arg(s), got 2 [wrong-arg-count]
         Expected: (self)
  Actually passed: (self, _)

When putting the two dataclasses into the same module, everything works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcat: corecore language and typing features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions