Skip to content

no-member error in annotations #6594

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

Closed
cdce8p opened this issue May 12, 2022 · 0 comments · Fixed by #6608
Closed

no-member error in annotations #6594

cdce8p opened this issue May 12, 2022 · 0 comments · Fixed by #6608
Labels
Enhancement ✨ Improvement to a component False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@cdce8p
Copy link
Member

cdce8p commented May 12, 2022

Bug description

First discovered in pylint-dev/astroid#1555

# pylint: disable=missing-docstring,unused-argument
from __future__ import annotations

import ast

def func(node: ast.Match) -> None:  # no-member
    ...

Configuration

No response

Command used

pylint test.py

Pylint output

test.py:6:15: E1101: Module 'ast' has no 'Match' member (no-member)

Expected behavior

With from __future__ import annotations, the type annotation isn't evaluated at runtime and thus won't throw an error. Furthermore it's possible to use classes that way which are only defined in stub files.

Similarly to string annotations, pylint should just ignore these cases and let type checker handle it.

Pylint version

pylint 2.14.0-b1
astroid 2.12.0-dev0
Python 3.9.12

OS / Environment

No response

Additional dependencies

No response

@cdce8p cdce8p added Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling Discussion 🤔 labels May 12, 2022
@cdce8p cdce8p changed the title no-member and undefined-variable error in annotations no-member error in annotations May 12, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.14.0 milestone May 13, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Enhancement ✨ Improvement to a component False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Discussion 🤔 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component 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