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 with keywords-only fields of dataclasses when using defaulted fields #7881

Closed
NeilGirdhar opened this issue Nov 30, 2022 · 0 comments · Fixed by pylint-dev/astroid#1970
Labels
dataclasses False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable
Milestone

Comments

@NeilGirdhar
Copy link

NeilGirdhar commented Nov 30, 2022

Bug description

This is a more complicated example than #5767

from dataclasses import KW_ONLY, dataclass, field

@dataclass
class Plotter:
    node_names: list[str] = field(default_factory=list)

@dataclass
class RewardsPlotter(Plotter):
    _: KW_ONLY
    smoothing: float

RewardsPlotter(smoothing=4.0)  # Unexpected keyword argument

Pylint output

a.py:13:0: E1123: Unexpected keyword argument 'smoothing' in constructor call (unexpected-keyword-arg)

Expected behavior

No error

Pylint version

pylint 2.16.0-dev
astroid 2.12.13
Python 3.10.4 (main, Apr  7 2022, 10:39:08) [GCC 11.2.0]

OS / Environment

No response

Additional dependencies

No response

@NeilGirdhar NeilGirdhar added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Nov 30, 2022
@DanielNoord DanielNoord added Needs astroid update Needs an astroid update (probably a release too) before being mergable dataclasses False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Nov 30, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.16.0 milestone Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dataclasses False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants