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

Inconsistent undefined-variable reporting #5399

Closed
jolaf opened this issue Nov 25, 2021 · 4 comments · Fixed by #5727
Closed

Inconsistent undefined-variable reporting #5399

jolaf opened this issue Nov 25, 2021 · 4 comments · Fixed by #5727
Labels
Bug 🪲 False Negative 🦋 No message is emitted but something is wrong with the code
Milestone

Comments

@jolaf
Copy link

jolaf commented Nov 25, 2021

Bug description

The following code:

# pylint: disable=multiple-statements, no-self-use, unused-argument, used-before-assignment
class A:
    def x(self, o: A) -> bool: ...
    def z(self) -> A: ...
    def t(self) -> A: ...

produces only 1 error report instead of 3.

Command used

pylint test.pyi

Pylint output

test.pyi:5: [E0602(undefined-variable), A.z] Undefined variable 'A'

Expected behavior

Error should be reported in lines 3, 4 and 5.

Pylint version

pylint 2.12.1
astroid 2.9.0
Python 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0]

OS / Environment

Ubuntu 20.04.3 LTS \n \l

Linux ubuntu 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

@jolaf jolaf added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Nov 25, 2021
@jacobtylerwalls
Copy link
Member

Might be the same as #5326, and in fact, I would be willing to rephrase it if you can help me :-).

@jacobtylerwalls
Copy link
Member

I think what they share is the second instance of the name "consuming" the first instance where the first instance is a type annotation.

@jolaf
Copy link
Author

jolaf commented Nov 25, 2021

Might be the same as #5326, and in fact, I would be willing to rephrase it if you can help me :-).

How can I help?

@cdce8p
Copy link
Member

cdce8p commented Dec 2, 2021

Pylint doesn't work too well for pyi files at the moment 😕
I would recommend a type checker for these cases. E.g. mypy or pyright.

jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Jan 26, 2022
… a type annotation is accessed multiple times
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Jan 26, 2022
… a type annotation is accessed multiple times
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Jan 26, 2022
… a type annotation is accessed multiple times
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Jan 26, 2022
… a type annotation is accessed multiple times
@Pierre-Sassoulas Pierre-Sassoulas added False Negative 🦋 No message is emitted but something is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jan 26, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.13.0 milestone Jan 26, 2022
Pierre-Sassoulas pushed a commit that referenced this issue Jan 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 False Negative 🦋 No message is emitted but something is wrong with the code
Projects
None yet
4 participants