Pylint: inherit-non-class false positive: NamedTuple (Python 3.9)

Created on 5 Oct 2020  路  7Comments  路  Source: PyCQA/pylint

Steps to reproduce

class Employee(NamedTuple):
    name: str
    id: int

Current behavior

E0239: Inheriting 'NamedTuple', which is not a class. (inherit-non-class)

Expected behavior

no error

pylint --version output

$ pylint --version
pylint 2.6.0
astroid 2.4.2
Python 3.9.0rc2+ (heads/3.9:d571924, Oct  5 2020, 11:56:25)
[Clang 9.0.0 (clang-900.0.39.2)]
bug false-positive help wanted python 3.9

Most helpful comment

I also receive the pylint warning: "R0903: Too few public methods (0/2) (too-few-public-methods)" on NamedTuples in python 3.9.0.
Am I right to assume that this unexpected warning is also part of this bug report?

All 7 comments

@belm0 thanks for the report. I can reproduce it (i need to import NamedTuple from typing module). It seems to be specific to python 3.9 as there is not such error with python 3.8.

yes, is should be labeled with "regression" if possible

@belm0 this is not a pylint regression because the pylint behavior has not changed. It is "just" an adaptation to python 3.9 that need to be handled.

@tirkarthi thanks for your comment. It is indeed the same issue as #3884. I keep this issue open and close #3884.

I also receive the pylint warning: "R0903: Too few public methods (0/2) (too-few-public-methods)" on NamedTuples in python 3.9.0.
Am I right to assume that this unexpected warning is also part of this bug report?

@pjljvandelaar you are right. Both problem arise from the same reason. It is also linked to #3895 and should be addressed soon, once PyCQA/astroid#858 will be merged.

Was this page helpful?
0 / 5 - 0 ratings