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

invalid-name type alias false-positive for union values #8487

Closed
The-Compiler opened this issue Mar 23, 2023 · 4 comments · Fixed by #8489, #8521 or #9093
Closed

invalid-name type alias false-positive for union values #8487

The-Compiler opened this issue Mar 23, 2023 · 4 comments · Fixed by #8489, #8521 or #9093
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Regression
Milestone

Comments

@The-Compiler
Copy link
Contributor

Bug description

With something like:

# pylint: disable=missing-docstring
from typing import Union
x: Union[str, int] = 42

pylint claims a wrong type alias name, with no type aliases involved.

Configuration

No response

Command used

pylint test.py

Pylint output

************* Module test
.../test.py:3:0: C0103: Type alias name "x" doesn't conform to predefined naming style (invalid-name)

Expected behavior

No output

Pylint version

pylint 2.17.0
astroid 2.15.0
Python 3.10.10 (main, Mar  5 2023, 22:26:53) [GCC 12.2.1 20230201]

also reproducible with the current main branches:

pylint 3.0.0a6
astroid 2.16.0dev0
Python 3.10.10 (main, Mar  5 2023, 22:26:53) [GCC 12.2.1 20230201]

OS / Environment

No response

Additional dependencies

No response

@The-Compiler The-Compiler added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Mar 23, 2023
@The-Compiler
Copy link
Contributor Author

Weirdly enough, the PR even adjusts an existing test to fit this (IMHO clearly wrong) naming scheme for a variable (not a type!): https://github.com/PyCQA/pylint/pull/7116/files#diff-53259554143b2179e9e991fecf0879ac4c0eaf61d5f58360ce4491c62f72c6b5

@DanielNoord
Copy link
Collaborator

Which test are you referring to in that diff?

@The-Compiler
Copy link
Contributor Author

tests/functional/r/regression_02/regression_3979.py with:

-foo: Union[str, BasePathLike] = "bar"
+Foo: Union[str, BasePathLike] = "bar"

The-Compiler added a commit to qutebrowser/qutebrowser that referenced this issue Mar 23, 2023
The-Compiler added a commit to qutebrowser/qutebrowser that referenced this issue Mar 23, 2023
@DanielNoord
Copy link
Collaborator

That fix is because we disallow foo as variable name in our configuration and this now gets flagged because we started checking these kind of assignments.

But, this is indeed a false positive that flew under the radar. I'm checking if I can easily fix this!

@DanielNoord DanielNoord added this to the 2.17.2 milestone Mar 23, 2023
@DanielNoord DanielNoord added Regression 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 Mar 23, 2023
@DanielNoord DanielNoord self-assigned this Mar 23, 2023
This was referenced Mar 31, 2023
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 Regression
Projects
None yet
2 participants