summaryrefslogtreecommitdiff
path: root/src/flake8/utils.py
diff options
context:
space:
mode:
authorEric N. Vander Weele <ericvw@gmail.com>2019-07-28 10:39:27 -0400
committerEric N. Vander Weele <ericvw@gmail.com>2019-07-28 10:43:02 -0400
commit9283f2f03f5c8e61eb5a6bca2f10afadb0d90317 (patch)
tree412c412c1601ffa141f49f5f3ebf472bed15e10e /src/flake8/utils.py
parent9fbaf2d2ea49adb97cc45be83a966fb3c7f292f2 (diff)
downloadflake8-9283f2f03f5c8e61eb5a6bca2f10afadb0d90317.tar.gz
utils: Change `parse_comma_separated_list()` contract
This is the initial incision point to only accept `str` (or `None`) for parsing out comma/whitespace/regexp separated values.
Diffstat (limited to 'src/flake8/utils.py')
-rw-r--r--src/flake8/utils.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/flake8/utils.py b/src/flake8/utils.py
index cf88648..06a1db1 100644
--- a/src/flake8/utils.py
+++ b/src/flake8/utils.py
@@ -24,11 +24,11 @@ string_types = (str, type(u""))
def parse_comma_separated_list(value, regexp=COMMA_SEPARATED_LIST_RE):
- # type: (Union[Sequence[str], str], Pattern[str]) -> List[str]
+ # type: (Optional[str], Pattern[str]) -> List[str]
"""Parse a comma-separated list.
:param value:
- String or list of strings to be parsed and normalized.
+ String to be parsed and normalized.
:param regexp:
Compiled regular expression used to split the value when it is a
string.
@@ -46,10 +46,8 @@ def parse_comma_separated_list(value, regexp=COMMA_SEPARATED_LIST_RE):
if not value:
return []
- if isinstance(value, string_types):
- value = regexp.split(value)
-
- item_gen = (item.strip() for item in value)
+ separated = regexp.split(value)
+ item_gen = (item.strip() for item in separated)
return [item for item in item_gen if item]