diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-07-26 19:41:41 -0500 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-07-26 19:45:05 -0500 |
| commit | e51fc5458b81b6c56c359c79b13ce88b70e476ec (patch) | |
| tree | fc869436089258d822661fa22e32a6c86b8d41e7 /src/flake8/defaults.py | |
| parent | 6eca38f2f2a15765aecef010f878aa17fdbe1db7 (diff) | |
| download | flake8-e51fc5458b81b6c56c359c79b13ce88b70e476ec.tar.gz | |
Fix handling of logical lines with noqa
When attempting to centralize all inline NoQA handling in the StyleGuide
we inadvertently broke plugins relying on it in combination with checker
state. For example, the check for E402 relies both on NoQA and the state
to determine if it has seen a non-import line. Placing NoQA on the sole
line that is not an import is more elegant than placing it on each of
the following import lines.
Closes #186
Diffstat (limited to 'src/flake8/defaults.py')
| -rw-r--r-- | src/flake8/defaults.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/flake8/defaults.py b/src/flake8/defaults.py index ede2946..73cadf1 100644 --- a/src/flake8/defaults.py +++ b/src/flake8/defaults.py @@ -1,4 +1,5 @@ """Constants that define defaults.""" +import re EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg' IGNORE = 'E121,E123,E126,E226,E24,E704,W503,W504' @@ -15,3 +16,19 @@ STATISTIC_NAMES = ( 'physical lines', 'tokens', ) + +NOQA_INLINE_REGEXP = re.compile( + # We're looking for items that look like this: + # ``# noqa`` + # ``# noqa: E123`` + # ``# noqa: E123,W451,F921`` + # ``# NoQA: E123,W451,F921`` + # ``# NOQA: E123,W451,F921`` + # We do not care about the ``: `` that follows ``noqa`` + # We do not care about the casing of ``noqa`` + # We want a comma-separated list of errors + '# noqa(?:: (?P<codes>[A-Z0-9,]+))?', + re.IGNORECASE +) + +NOQA_FILE = re.compile(r'\s*# flake8[:=]\s*noqa', re.I) |
