Skip to content

(no-value-for-parameter) on dataclass field attribute C0114 #5225

@tweigel-dev

Description

@tweigel-dev

Bug description

hay,
at working with dataclasses and pylint I noticed that pylint outputs a missleading error for generated attributes of dataclass.

from dataclasses import dataclass, field


@dataclass
class Person:
    """
    Class implementation to forecast on PRB
    """
    # pylint: disable=missing-function-docstring, too-many-instance-attributes, function-redefined,
    name: str
    last_char: int = field(init=True)

    @property
    def last_char(self):
        return self.name[-1]

    @last_char.setter
    def last_char(self, _):
        pass  # Do nothing, this is a read-only attribute

print(Person("Manfred"))

I got E1120: No value for argument 'last_char' in constructor call (no-value-for-parameter)

Command used

pylint ./bug-dataclasses.py

Pylint output

E1120: No value for argument 'last_char' in constructor call (no-value-for-parameter)

Expected behavior

No lint error

Pylint version

pylint 2.11.1
astroid 2.8.4
Python 3.9.5 (default, May 19 2021, 11:32:47) 
[GCC 9.3.0]

Metadata

Metadata

Assignees

Labels

Bug 🪲False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds astroid updateNeeds an astroid update (probably a release too) before being mergabledataclasses

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions