Skip to content

[Bug] Issue with inherited keyword dataclass fields #7623

@giodall

Description

@giodall

Bug description

this issue seems to be close to #5767, but for inherited dataclasses:

@dataclass class Parent: p1: int = field(kw_only=True, default=0) @dataclass class Child(Parent): c1: str Child('') Child('', p1=1) # redundant-keyword-arg" : "Argument 'p1' passed by position and keyword in constructor call" Child(c1='') # "unexpected-keyword-arg": "Unexpected keyword argument 'c1' in constructor call" Child(c1='', p1=5) # "unexpected-keyword-arg": "Unexpected keyword argument 'c1' in constructor call"

Configuration

No response

Command used

pylint a.py

Pylint output

[{ "code": "redundant-keyword-arg", "message": "Argument 'p1' passed by position and keyword in constructor call", },{ "code": "unexpected-keyword-arg", "message": "Unexpected keyword argument 'c1' in constructor call", },{ "code": "unexpected-keyword-arg", "message": "Unexpected keyword argument 'c1' in constructor call", }]

Expected behavior

no errors

Pylint version

pylint 2.15.4 astroid 2.12.11 Python 3.10.0 (v3.10.0:b494f5935c, Oct 4 2021, 14:59:20) [Clang 12.0.5 (clang-1205.0.22.11)]

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions