Repository navigation
Conversation
Single-character uppercase names (such as `F` or `Q`) are valid CapWords class names under PEP 8. Allow aliasing them to CapWords names without triggering N811 while still rejecting lowercase, mixedCase, and underscore-separated non-constant aliases. Fixes PyCQA#232
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Single-character uppercase identifiers (such as
ForQinfrom django.db.models import F as Field) are validCapWordsclass namesunder PEP 8 (
N801), butoriginal_name.isupper()inImportAsCheck.visit_importfrompreviously treated every uppercase identifierexclusively as a constant and emitted false-positive
N811errors whenaliased to a
CapWordsname.Changes
ImportAsCheck.visit_importfrom, allow single-character uppercaseidentifiers (
len(original_name.strip('_')) == 1) to be imported with aCapWordsalias (is_capwords(asname)) without triggeringN811, whilecontinuing to allow
UPPER_CASEconstant aliases and continuing to flaglowercase,
mixedCase, or underscore-separated non-constant aliases (aswell as multi-character constants imported as
CapWords).testsuite/N81x.py.Fixes #232