Skip to content

Unexpected kwarg false-positive when using TypeVarTuple #10991

@kdkavanagh

Description

@kdkavanagh

Bug description

a @DataClass base defines a field, and two child classes both use
PEP 695 TypeVarTuple syntax (*Shape) with the TypeVarTuple forwarded in
the parent specialization (Middle[T, *Shape]). Pylint loses track of the
inherited field through the forwarded TypeVarTuple chain.

Likely related to #10972

from dataclasses import dataclass

@dataclass(frozen=True, kw_only=True)
class Base:
    value: str

@dataclass(frozen=True, kw_only=True)
class Middle[T, *Shape](Base):
    pass

@dataclass(frozen=True, kw_only=True)
class Upper[T, *Shape](Middle[T, *Shape]):
    pass

obj = Upper[str, int](value="hello")

Command used

pylint -vv

Pylint output

E1123: Unexpected keyword argument 'value' in constructor call

Expected behavior

No error raised

Pylint version

$ pylint --version
pylint 4.0.5                                                                                             
astroid 4.0.4                                                                                            
Python 3.12.6 (main, Oct  9 2024, 11:19:43) [GCC 13.2.0]

OS / Environment

No response

Additional dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs triage 📥Just created, needs acknowledgment, triage, and proper labelling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions