Skip to content

Conversation

@mtmiller
Copy link
Contributor

@mtmiller mtmiller commented Jun 2, 2016

Fix for #341. Could be improved further to include named parameters, maybe other cases I can't think of where names are declared.

mtmiller added 2 commits June 2, 2016 14:32
Check for prohibited identifiers occuring to the lhs of an assignment
operator or after the 'as' keyword.

Closes PyCQA#341
one and zero. When tempted to use 'l', use 'L' instead.

Okay: L = 0
E741: l = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mtmiller ! Could you update the doc tests with the rest of the cases that are not allowed?

Also, the 'as' test cases are missing.

@mtmiller
Copy link
Contributor Author

mtmiller commented Jun 2, 2016

Further doctests for all 3 forbidden variable names added, as well as some tests on except/as and with/as.

While hacking on this I realized I missed some other obvious cases such as for loop iterators and initialization of a list of variables such as I, J, K = ....

@mtmiller
Copy link
Contributor Author

mtmiller commented Jun 3, 2016

Added checks for names after class, def, global, and nonlocal, with new error IDs for function and class definitions versus local variables.

Now reports errors for almost everything in the original example in #341.

Still missing checks for for loop iterators, function parameters, and the comma-separated lists of variables that can appear in assignments, for loops, arg lists, and global and nonlocal statements.

@sigmavirus24
Copy link
Member

This will have to be included in 2.1.0 or some other 2.x.0 release.

@sigmavirus24 sigmavirus24 changed the title Issue341 Detect single letter variable names enumerated in PEP-0008 Jun 4, 2016
@sigmavirus24 sigmavirus24 added this to the 2.1 milestone Jun 4, 2016
@IanLee1521
Copy link
Member

Next version will be 2.1.0, going to go ahead and merge this. Thanks @mtmiller !

@IanLee1521 IanLee1521 merged commit 4ccdc55 into PyCQA:master Jun 7, 2016
@mtmiller mtmiller deleted the issue341 branch June 7, 2016 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants