Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
N811 & N814: eliminate false positives for single-letter names #14584
N811 & N814: eliminate false positives for single-letter names #14584
Changes from 5 commits
3bd7fd2
3da4c28
b56d933
9396f38
c811971
1732d6b
cfc70bb
3de5771
d261a0e
e9af7fa
7ae363c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we still want to forbid things like
from foo import C as c
from one of these rules, right? Won't these changes mean that we will no longer see that error?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not possible to tell if
C
is a class or a constant. So even thoughfrom foo import C as c
might not be advisable, it's not applicable to throw an error about this under a rule made for constants.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But regardless of whether you classify its original name as CamelCase or SCREAMING_SNAKE_CASE, the name it's being aliased to is neither CamelCase nor SCREAMING_SNAKE_CASE. I don't mind much which of these two rules flags that, but I think I would want a rule in this category to complain that the alias uses a different naming convention to the naming convention used for the object's original name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could add a new rule,
non_lowercase_imported_as_lowercase
? (to compliment the already-existinglowercase_imported_as_non_lowercase
).Though I guess we'd need to prevent overlaps and check that the other rules aren't already firing?
Or maybe just name it
single_uppercase_character_imported_as_lowercase
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to preserve the existing behavior for lower-case letters which is that both rules falg it?
Nice catch @AlexWaygood !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that could be an option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just pushed a change that makes N811 flags it. I think that rule makes more sense here, and I think it's not a great outcome if one lint error is flagged by two rules. I don't think the situation is common enough to justify its own rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't disagree with this. I'm just slightly worried about bug reports if someone only enables one rule... But I'm fine with either