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

Incorrect "undefined variable" error for named tuple class variables as return type annotations #5568

Closed
aborealis opened this issue Dec 20, 2021 · 0 comments · Fixed by #5688
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@aborealis
Copy link

Bug description

pylint seems to incorrectly identify an undefined variable error when using a namedtuple class variable as a return type annotation. Argument type annotations appear to be OK.

Steps to reproduce

# main.py
from collections import namedtuple

class MyObject:
    Coords = namedtuple('Point', ['x', 'y'])
 
    def my_method(self) -> Coords:
        pass

Configuration

No response

Command used

pylint

Pylint output

************* Module main
main.py:161:43: E0602: Undefined variable 'Coords' (undefined-variable)

Expected behavior

no errors

Pylint version

pylint 2.12.2
astroid 2.9.0
Python 3.9.9 (main, Nov 16 2021, 10:24:31) 
[GCC 11.2.0]

OS / Environment

Kali Liniux

Additional dependencies

No response

@aborealis aborealis added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Dec 20, 2021
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this issue Jan 16, 2022
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jan 16, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.13.0 milestone Jan 16, 2022
Pierre-Sassoulas added a commit that referenced this issue Jan 16, 2022
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants