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

Annotated module level constant not checked for invalid-name #9770

Open
jacobtylerwalls opened this issue Jul 7, 2024 · 7 comments · May be fixed by #9771
Open

Annotated module level constant not checked for invalid-name #9770

jacobtylerwalls opened this issue Jul 7, 2024 · 7 comments · May be fixed by #9771
Assignees
Labels
C: invalid-name False Negative 🦋 No message is emitted but something is wrong with the code Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Milestone

Comments

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Jul 7, 2024

Originally reported by @mbyrnepr2 in #7232 (comment).

Bug description

"""should raise invalid-name"""
my_var: int = 1

Configuration

No response

Command used

pylint a.py

Pylint output

% pylint x.py

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 0.00/10, +10.00)

Expected behavior

invalid-name

Pylint version

pylint 3.3.0-dev0
astroid 3.3.0-dev0
Python 3.13.0b3

OS / Environment

No response

Additional dependencies

No response

@jacobtylerwalls jacobtylerwalls added Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling False Negative 🦋 No message is emitted but something is wrong with the code C: invalid-name labels Jul 7, 2024
@jacobtylerwalls jacobtylerwalls self-assigned this Jul 7, 2024
@jacobtylerwalls jacobtylerwalls added this to the 3.3.0 milestone Jul 7, 2024
@mbyrnepr2
Copy link
Member

I may have gotten that all wrong.
If the snake-cased module-level name is annotated with something other then Final, then perhaps it is fair to say it is not intended to be a constant and, so, Pylint should not expect that to be uppercase.

@jacobtylerwalls
Copy link
Member Author

You did identify a real issue -- annotated statements at the module level are completely escaping any sort of checking for invalid-name -- that can't be right!

@jacobtylerwalls
Copy link
Member Author

We can discuss what to do in finer-grained detail for these cases in #3585, but for now, suggest to just make my_var: int do the same check as my_var.

@Pierre-Sassoulas
Copy link
Member

I agree it's a bug but it's going to create a lot of new messages / spam for a patch (or even a minor) version. I think we should wait for #3585 (comment) to be implemented before merging it (it's as simple as a regex change, right ?).

@jacobtylerwalls
Copy link
Member Author

Not a regex but something more like a refactor to let the invalid name check do "as-if" checks so a name can be checked twice against two regexes.

But yeah, happy to hold this until somebody works on the other one.

@jacobtylerwalls
Copy link
Member Author

Hm, if the other change is waiting for 4.0 are we willing to let this wait that long also?

@DanielNoord
Copy link
Collaborator

I'm fine with waiting. Bit annoying for users to introduce behaviour that gets replaced a couple of versions later again.

@jacobtylerwalls jacobtylerwalls modified the milestones: 3.3.0, 4.0.0 Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: invalid-name False Negative 🦋 No message is emitted but something is wrong with the code Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants