Filter out empty ignore/select codes

When we parse out our comma separated lists, we should ignore empty
strings to avoid them breaking users' expectations.

Closes #330
This commit is contained in:
Ian Cordasco 2017-05-20 20:26:27 -05:00
parent deb4936f5d
commit 25566468a2
No known key found for this signature in database
GPG key ID: 656D3395E4A9791A
2 changed files with 7 additions and 1 deletions

View file

@ -29,7 +29,8 @@ def parse_comma_separated_list(value):
if not isinstance(value, (list, tuple)):
value = value.split(',')
return [item.strip() for item in value]
item_gen = (item.strip() for item in value)
return [item for item in item_gen if item]
def normalize_paths(paths, parent=os.curdir):

View file

@ -13,8 +13,13 @@ 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,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"]),
])
def test_parse_comma_separated_list(value, expected):
"""Verify that similar inputs produce identical outputs."""