pylint
pylint copied to clipboard
False positive for missing-kwoa (E1125) on inherited dataclasses with kw_only=True
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
pylint --enable=missing-kwoa minimal.py try use this cmd
The false positive is still there, obviously.
+1