Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
belm0 opened this issue Oct 5, 2020 · 7 comments · Fixed by pylint-dev/astroid#858
Closed

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

belm0 opened this issue Oct 5, 2020 · 7 comments · Fixed by pylint-dev/astroid#858
Assignees
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code Help wanted 🙏 Outside help would be appreciated, good for new contributors python 3.9

Comments

@belm0
Copy link
Contributor

belm0 commented Oct 5, 2020

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)]
@hippo91
Copy link
Contributor

hippo91 commented Oct 10, 2020

@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.

@hippo91 hippo91 added Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code Help wanted 🙏 Outside help would be appreciated, good for new contributors python 3.9 labels Oct 10, 2020
@belm0
Copy link
Contributor Author

belm0 commented Oct 10, 2020

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

@hippo91
Copy link
Contributor

hippo91 commented Oct 10, 2020

@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
Copy link

Seems to be same as #3884. This was raised upstream : https://bugs.python.org/issue41973

@hippo91
Copy link
Contributor

hippo91 commented Oct 11, 2020

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

@pjljvandelaar
Copy link

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?

ssbarnea added a commit to ansible/molecule that referenced this issue Oct 15, 2020
Includes workaround for pylint bug when run with python3.9 around
NamedTuple.

Related: pylint-dev/pylint#3876
ssbarnea added a commit to ansible/molecule that referenced this issue Oct 15, 2020
Includes workaround for pylint bug when run with python3.9 around
NamedTuple.

Related: pylint-dev/pylint#3876
simu added a commit to projectsyn/commodore that referenced this issue Oct 19, 2020
Python 3.9 changed typing.NamedTuple to be a function that can be
inherited from. This trips up pylint, cf.
pylint-dev/pylint#3876.
simu added a commit to projectsyn/commodore that referenced this issue Oct 19, 2020
Python 3.9 changed typing.NamedTuple to be a function that can be
inherited from. This trips up pylint, cf.
pylint-dev/pylint#3876.
@hippo91 hippo91 self-assigned this Oct 31, 2020
@hippo91
Copy link
Contributor

hippo91 commented Nov 24, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code Help wanted 🙏 Outside help would be appreciated, good for new contributors python 3.9
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants