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 for missing-kwoa (E1125) on inherited dataclasses with kw_only=True #9518

Open
taschini opened this issue Mar 23, 2024 · 2 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@taschini
Copy link

taschini commented Mar 23, 2024

Bug description

This code is fine:

# minimal.py
from dataclasses import dataclass, field


@dataclass(kw_only=True)
class Base:
    x: int
    y: int


class SumMixin:

    def sum(self):
        return self.x + self.y


@dataclass(kw_only=True)
class Intermediate(Base, SumMixin):

    x: int = field(init=False)

    def __post_init__(self):
        self.x = 4


@dataclass(kw_only=True)
class Example(Intermediate):

    message: str

    def help(self):
        return self.message.format(self.sum())


if __name__ == "__main__":
    print(Example(y=3, message="Here it is: {}").sum())

Configuration

No response

Command used

pylint --disable=all --enable=missing-kwoa minimal.py

Pylint output

************* Module minimal
minimal.py:34:10: E1125: Missing mandatory keyword argument 'x' in constructor call (missing-kwoa)

Expected behavior

There should be no findings.

Pylint version

pylint 3.1.0
astroid 3.1.0
Python 3.11.6 (main, Nov 20 2023, 13:25:53) [GCC 11.4.0]

OS / Environment

No response

Additional dependencies

No response

@taschini taschini added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Mar 23, 2024
@taschini taschini changed the title False positive for missing-kwoa (E1125) on inherited dataclasses with kw_obnly=True False positive for missing-kwoa (E1125) on inherited dataclasses with kw_only=True Mar 23, 2024
@joel6948
Copy link

joel6948 commented Apr 1, 2024

pylint --enable=missing-kwoa minimal.py
try use this cmd

@taschini
Copy link
Author

taschini commented Apr 2, 2024

The false positive is still there, obviously.

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

2 participants