Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive arguments-differ on __post_init__ method in dataclass inheritence #9804

Open
e-gebes opened this issue Jul 16, 2024 · 0 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@e-gebes
Copy link

e-gebes commented Jul 16, 2024

Bug description

from dataclasses import InitVar
from dataclasses import dataclass


@dataclass
class Base:
    x: int

    def __post_init__(self):
        self.x += 1


@dataclass
class Child(Base):
    y: InitVar[int]

    def __post_init__(self, y):  # this is OK but it triggers `arguments-differ`
        super().__post_init__()
        self.x += y

Configuration

No response

Command used

pylint a.py

Pylint output

************* Module a
17:4: W0221: Number of parameters was 1 in 'Base.__post_init__' and is now 2 in overriding 'Child.__post_init__' method (arguments-differ)

Expected behavior

no warning should be reported

Pylint version

pylint 2.17.7
astroid 2.15.8
Python 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0]

OS / Environment

No response

Additional dependencies

No response

@e-gebes e-gebes added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

1 participant