mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 10:46:54 +00:00
Merge branch 'bug/329' into 'master'
Avoid bugs when users accidentally forget a comma Closes #329 See merge request !185
This commit is contained in:
commit
d890b8b683
3 changed files with 12 additions and 1 deletions
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
You can view the `3.4.0 milestone`_ on GitLab for more details.
|
||||
|
||||
- Handle spaces as an alternate separate for error codes, e.g.,
|
||||
``--ignore 'E123 E234'``. (See also `GitLab#329`_)
|
||||
|
||||
- Filter out empty select and ignore codes, e.g., ``--ignore E123,,E234``.
|
||||
(See also `GitLab#330`_)
|
||||
|
||||
|
|
@ -11,6 +14,8 @@ You can view the `3.4.0 milestone`_ on GitLab for more details.
|
|||
https://gitlab.com/pycqa/flake8/milestones/18
|
||||
|
||||
.. issue links
|
||||
.. _GitLab#329:
|
||||
https://gitlab.com/pycqa/flake8/issues/329
|
||||
.. _GitLab#330:
|
||||
https://gitlab.com/pycqa/flake8/issues/330
|
||||
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue