Pylint: "no-member" false positive for basic dataclass in 2.4.1

Created on 25 Sep 2019  路  3Comments  路  Source: PyCQA/pylint

Steps to reproduce

Run pylint vs the following example

from __future__ import annotations
from dataclasses import dataclass


@dataclass
class Point:
    x: int
    y: int
    dx: int
    dy: int

    def move(self):
        self.x += self.dx
        self.y += self.dy

Current behavior

sample.py:13:8: E1101: Instance of 'Point' has no 'x' member; maybe 'y'? (no-member)
sample.py:14:8: E1101: Instance of 'Point' has no 'y' member; maybe 'x'? (no-member)

Expected behavior

No warnings are expected I guess. Before updating to 2.4.0 there were no reports.

pylint --version output

pylint 2.4.1
astroid 2.3.0
Python 3.7.4 (v3.7.4:e09359112e, Jul  8 2019, 14:54:52) 
[Clang 6.0 (clang-600.0.57)]
bug

Most helpful comment

This should be fixed with https://github.com/PyCQA/astroid/commit/3e4eac76e9abfa0400fa07b58c61973ac5495bd2 which will be part of astroid 2.3.1 shortly.

All 3 comments

Another example that had no errors in 2.3.1 but fails with no-member in 2.4.1:

from dataclasses import dataclass


@dataclass
class MyClass:
    attribute: str


@dataclass
class MyChildClass(MyClass):
    def method(self):
        print(self.attribute)  # no-member

Failing versions

astroid==2.3.0
pylint==2.4.1

Passing versions:

astroid==2.2.4
pylint==2.3.1

This should be fixed with https://github.com/PyCQA/astroid/commit/3e4eac76e9abfa0400fa07b58c61973ac5495bd2 which will be part of astroid 2.3.1 shortly.

Fedora 31: bug triggered.
Fedora 31 + updates: bug fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PCManticore picture PCManticore  路  3Comments

DGalt picture DGalt  路  3Comments

thanatos picture thanatos  路  3Comments

GergelyKalmar picture GergelyKalmar  路  3Comments

glmdgrielson picture glmdgrielson  路  3Comments