pylint
pylint copied to clipboard
`E1124:redundant-keyword-arg` false positive on dataclass with `kw_only=False` that extends dataclass with `kw_only=True`
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