mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 22:04:17 +00:00
Assign missing codes to PyFlakes messages
Some PyFlakes messages weren't covered by unique messages, making them impossible to select/ignore. This is now fixed. To ensure we don't regress in the future, a test has been added that fails if there's any uncovered messages.
This commit is contained in:
parent
b8ce1334d0
commit
2f1338c342
4 changed files with 85 additions and 18 deletions
|
|
@ -17,27 +17,44 @@ import pyflakes.checker
|
|||
from flake8 import utils
|
||||
|
||||
|
||||
FLAKE8_PYFLAKES_CODES = dict([line.split()[::-1] for line in (
|
||||
'F401 UnusedImport',
|
||||
'F402 ImportShadowedByLoopVar',
|
||||
'F403 ImportStarUsed',
|
||||
'F404 LateFutureImport',
|
||||
'F405 ImportStarUsage',
|
||||
'F406 ImportStarNotPermitted',
|
||||
'F407 FutureFeatureNotDefined',
|
||||
'F601 MultiValueRepeatedKeyLiteral',
|
||||
'F602 MultiValueRepeatedKeyVariable',
|
||||
'F621 TooManyExpressionsInStarredAssignment',
|
||||
'F622 TwoStarredExpressions',
|
||||
'F631 AssertTuple',
|
||||
'F701 BreakOutsideLoop',
|
||||
'F702 ContinueOutsideLoop',
|
||||
'F703 ContinueInFinally',
|
||||
'F704 YieldOutsideFunction',
|
||||
'F705 ReturnWithArgsInsideGenerator',
|
||||
'F706 ReturnOutsideFunction',
|
||||
'F707 DefaultExceptNotLast',
|
||||
'F721 DoctestSyntaxError',
|
||||
'F811 RedefinedWhileUnused',
|
||||
'F812 RedefinedInListComp',
|
||||
'F821 UndefinedName',
|
||||
'F822 UndefinedExport',
|
||||
'F823 UndefinedLocal',
|
||||
'F831 DuplicateArgument',
|
||||
'F841 UnusedVariable',
|
||||
)])
|
||||
|
||||
|
||||
def patch_pyflakes():
|
||||
"""Add error codes to Pyflakes messages."""
|
||||
codes = dict([line.split()[::-1] for line in (
|
||||
'F401 UnusedImport',
|
||||
'F402 ImportShadowedByLoopVar',
|
||||
'F403 ImportStarUsed',
|
||||
'F404 LateFutureImport',
|
||||
'F405 ImportStarUsage',
|
||||
'F810 Redefined',
|
||||
'F811 RedefinedWhileUnused',
|
||||
'F812 RedefinedInListComp',
|
||||
'F821 UndefinedName',
|
||||
'F822 UndefinedExport',
|
||||
'F823 UndefinedLocal',
|
||||
'F831 DuplicateArgument',
|
||||
'F841 UnusedVariable',
|
||||
)])
|
||||
|
||||
for name, obj in vars(pyflakes.messages).items():
|
||||
if name[0].isupper() and obj.message:
|
||||
obj.flake8_msg = '%s %s' % (codes.get(name, 'F999'), obj.message)
|
||||
obj.flake8_msg = '%s %s' % (
|
||||
FLAKE8_PYFLAKES_CODES.get(name, 'F999'), obj.message
|
||||
)
|
||||
|
||||
|
||||
patch_pyflakes()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue