From ec996ffd85cbe6157b7cf480e7c84b36d2153f4b Mon Sep 17 00:00:00 2001 From: Ian Stapleton Cordasco Date: Fri, 28 Jul 2017 19:31:32 -0500 Subject: [PATCH] Allow spaces in # noqa lists To match our new configuration file format and its allowance for spaces in the list Closes #356 --- src/flake8/defaults.py | 2 +- tests/unit/test_utils.py | 1 + tests/unit/test_violation.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/flake8/defaults.py b/src/flake8/defaults.py index e8c6bfb..55cb48a 100644 --- a/src/flake8/defaults.py +++ b/src/flake8/defaults.py @@ -46,7 +46,7 @@ NOQA_INLINE_REGEXP = re.compile( # 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([A-Z][0-9]+,?)+))?', + '# noqa(?:: (?P([A-Z][0-9]+(?:[,\s]+)?)+))?', re.IGNORECASE ) diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index e50dade..9f3976f 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -19,6 +19,7 @@ RELATIVE_PATHS = ["flake8", "pep8", "pyflakes", "mccabe"] ("E123,W234,E206,", ["E123", "W234", "E206"]), ("E123,W234,E206, ,\n", ["E123", "W234", "E206"]), ("E123,W234,,E206,,", ["E123", "W234", "E206"]), + ("E123, W234,, E206,,", ["E123", "W234", "E206"]), ("E123,,W234,,E206,,", ["E123", "W234", "E206"]), (["E123", "W234", "E206"], ["E123", "W234", "E206"]), (["E123", "\n\tW234", "\n E206"], ["E123", "W234", "E206"]), diff --git a/tests/unit/test_violation.py b/tests/unit/test_violation.py index fa75278..c4b56b1 100644 --- a/tests/unit/test_violation.py +++ b/tests/unit/test_violation.py @@ -11,6 +11,7 @@ from flake8 import style_guide ('E121', 'a = 1 # noqa: E111,W123,F821', False), ('E111', 'a = 1 # noqa: E111,W123,F821', True), ('W123', 'a = 1 # noqa: E111,W123,F821', True), + ('W123', 'a = 1 # noqa: E111, W123,F821', True), ('E111', 'a = 1 # noqa: E11,W123,F821', True), ('E111', 'a = 1 # noqa, analysis:ignore', True), ('E111', 'a = 1 # noqa analysis:ignore', True),