Skip to content

Commit e7d64d3

Browse files
Improved parsing of multiline option values (including trailing commas)
1 parent 8aac6b5 commit e7d64d3

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

pep8.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,10 +2081,10 @@ def process_options(arglist=None, parse_argv=False, config_file=None,
20812081
options = read_config(options, args, arglist, parser)
20822082
options.reporter = parse_argv and options.quiet == 1 and FileReport
20832083

2084-
options.filename = options.filename and options.filename.split(',')
2084+
options.filename = _parse_multi_options(options.filename.split(','))
20852085
options.exclude = normalize_paths(options.exclude)
2086-
options.select = options.select and options.select.split(',')
2087-
options.ignore = options.ignore and options.ignore.split(',')
2086+
options.select = _parse_multi_options(options.select.split(','))
2087+
options.ignore = _parse_multi_options(options.ignore.split(','))
20882088

20892089
if options.diff:
20902090
options.reporter = DiffReport
@@ -2095,6 +2095,22 @@ def process_options(arglist=None, parse_argv=False, config_file=None,
20952095
return options, args
20962096

20972097

2098+
def _parse_multi_options(options):
2099+
r"""Split and strip and discard empties.
2100+
2101+
Turns the following:
2102+
2103+
A,
2104+
B,
2105+
2106+
into ["A", "B"]
2107+
"""
2108+
if options:
2109+
return [o.strip() for o in options if o.strip()]
2110+
else:
2111+
return options
2112+
2113+
20982114
def _main():
20992115
"""Parse options and run checks on Python source."""
21002116
import signal

0 commit comments

Comments
 (0)