diff options
| author | Ian Stapleton Cordasco <graffatcolmingov@gmail.com> | 2017-08-09 19:35:01 -0500 |
|---|---|---|
| committer | Ian Stapleton Cordasco <graffatcolmingov@gmail.com> | 2017-08-09 19:35:01 -0500 |
| commit | 222f0a8115651eecc4f88933bb887068427e97bf (patch) | |
| tree | 4584e6f37c8334f7c1ebbcc8b7e7e0f986cf53b4 /src/flake8/utils.py | |
| parent | a2c7051c9e4d42014620099743e449415d8cb450 (diff) | |
| download | flake8-222f0a8115651eecc4f88933bb887068427e97bf.tar.gz | |
Allow our local plugin parsing to accept commas
By slightly modifying our utility function to parse comma separated
lists we can parse local plugins similar to other configuration options.
Diffstat (limited to 'src/flake8/utils.py')
| -rw-r--r-- | src/flake8/utils.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/flake8/utils.py b/src/flake8/utils.py index 953b594..d28b810 100644 --- a/src/flake8/utils.py +++ b/src/flake8/utils.py @@ -11,14 +11,20 @@ import tokenize DIFF_HUNK_REGEXP = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$') COMMA_SEPARATED_LIST_RE = re.compile(r'[,\s]') +LOCAL_PLUGIN_LIST_RE = re.compile(r'[,\t\n\r\f\v]') -def parse_comma_separated_list(value): +def parse_comma_separated_list(value, regexp=COMMA_SEPARATED_LIST_RE): # type: (Union[Sequence[str], str]) -> List[str] """Parse a comma-separated list. :param value: String or list of strings to be parsed and normalized. + :param regexp: + Compiled regular expression used to split the value when it is a + string. + :type regexp: + _sre.SRE_Pattern :returns: List of values with whitespace stripped. :rtype: @@ -28,7 +34,7 @@ def parse_comma_separated_list(value): return [] if not isinstance(value, (list, tuple)): - value = COMMA_SEPARATED_LIST_RE.split(value) + value = regexp.split(value) item_gen = (item.strip() for item in value) return [item for item in item_gen if item] |
