Skip to content

E1124:redundant-keyword-arg false positive on dataclass with kw_only=False that extends dataclass with kw_only=True #7290

Closed
pylint-dev/astroid
#1764
@DetachHead

Description

@DetachHead

Bug description

import inspect
from dataclasses import dataclass


@dataclass(kw_only=True)
class Foo:
    a: int
    b: str


@dataclass(kw_only=False)
class Bar(Foo):
    c: int


print(inspect.signature(Bar.__init__))  # (self, c: int, *, a: int, b: str) -> None

a = Bar(1, a=2, b="")  # error: Argument 'a' passed by position and keyword in constructor call (E1124:redundant-keyword-arg)


print(a) # Bar(a=2, b='', c=1)

Configuration

No response

Command used

pylint asdf.py

Pylint output

************* Module asdf
asdf.py:18:4: E1124: Argument 'a' passed by position and keyword in constructor call (redundant-keyword-arg)

Expected behavior

no error

Pylint version

pylint 2.14.5
astroid 2.11.7
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

Labels

False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationNeeds astroid updateNeeds an astroid update (probably a release too) before being mergable

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions