diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2017-05-25 20:02:58 -0500 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2017-05-25 20:07:48 -0500 |
| commit | a42299d008df7054532d52f84b0795d0e76cf5a8 (patch) | |
| tree | 46aedbfdb28f4b42e7251cd6098a8c3b933c6943 | |
| parent | a36d44a70df131092ed2e9cdf0a767c08ecdb9f7 (diff) | |
| download | flake8-a42299d008df7054532d52f84b0795d0e76cf5a8.tar.gz | |
Support spaces as error/ignore code separators
Closes #329
| -rw-r--r-- | src/flake8/utils.py | 3 | ||||
| -rw-r--r-- | tests/unit/test_utils.py | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/flake8/utils.py b/src/flake8/utils.py index a4c67ce..953b594 100644 --- a/src/flake8/utils.py +++ b/src/flake8/utils.py @@ -10,6 +10,7 @@ import sys import tokenize DIFF_HUNK_REGEXP = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$') +COMMA_SEPARATED_LIST_RE = re.compile(r'[,\s]') def parse_comma_separated_list(value): @@ -27,7 +28,7 @@ def parse_comma_separated_list(value): return [] if not isinstance(value, (list, tuple)): - value = value.split(',') + value = COMMA_SEPARATED_LIST_RE.split(value) item_gen = (item.strip() for item in value) return [item for item in item_gen if item] diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 0a12f2d..e50dade 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -13,13 +13,18 @@ RELATIVE_PATHS = ["flake8", "pep8", "pyflakes", "mccabe"] @pytest.mark.parametrize("value,expected", [ ("E123,\n\tW234,\n E206", ["E123", "W234", "E206"]), ("E123,W234,E206", ["E123", "W234", "E206"]), + ("E123 W234 E206", ["E123", "W234", "E206"]), + ("E123\nW234 E206", ["E123", "W234", "E206"]), + ("E123\nW234\nE206", ["E123", "W234", "E206"]), ("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", "\n\tW234", "\n E206"], ["E123", "W234", "E206"]), (["E123", "\n\tW234", "\n E206", "\n"], ["E123", "W234", "E206"]), (["E123", "\n\tW234", "", "\n E206", "\n"], ["E123", "W234", "E206"]), + (["E123", "\n\tW234", "", "\n E206", ""], ["E123", "W234", "E206"]), ]) def test_parse_comma_separated_list(value, expected): """Verify that similar inputs produce identical outputs.""" |
