Skip to content

Commit f254233

Browse files
committed
Fixed regression which caused pep8 to not be able to pass in config file; issue #380
1 parent 8ca030e commit f254233

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pep8.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,11 +1779,13 @@ def __init__(self, *args, **kwargs):
17791779
# build options from the command line
17801780
self.checker_class = kwargs.pop('checker_class', Checker)
17811781
parse_argv = kwargs.pop('parse_argv', False)
1782+
config_file = kwargs.pop('config_file', False)
17821783
parser = kwargs.pop('parser', None)
17831784
# build options from dict
17841785
options_dict = dict(*args, **kwargs)
17851786
arglist = None if parse_argv else options_dict.get('paths', None)
1786-
options, self.paths = process_options(arglist, parse_argv, parser)
1787+
options, self.paths = process_options(
1788+
arglist, parse_argv, config_file, parser)
17871789
if options_dict:
17881790
options.__dict__.update(options_dict)
17891791
if 'paths' in options_dict:
@@ -2035,8 +2037,13 @@ def read_config(options, args, arglist, parser):
20352037
return options
20362038

20372039

2038-
def process_options(arglist=None, parse_argv=False, parser=None):
2039-
"""Process options passed either via arglist or via command line args."""
2040+
def process_options(arglist=None, parse_argv=False, config_file=None,
2041+
parser=None):
2042+
"""Process options passed either via arglist or via command line args.
2043+
2044+
Passing in the ``config_file`` parameter allows other tools, such as flake8
2045+
to specify their own options to be processed in pep8.
2046+
"""
20402047
if not parser:
20412048
parser = get_parser()
20422049
if not parser.has_option('--config'):
@@ -2045,7 +2052,7 @@ def process_options(arglist=None, parse_argv=False, parser=None):
20452052
"tox.ini file or the setup.cfg file located in any parent folder "
20462053
"of the path(s) being processed. Allowed options are: %s." %
20472054
(parser.prog, ', '.join(parser.config_options))))
2048-
group.add_option('--config', metavar='path', default=None,
2055+
group.add_option('--config', metavar='path', default=config_file,
20492056
help="user config file location")
20502057
# Don't read the command line if the module is used as a library.
20512058
if not arglist and not parse_argv:

0 commit comments

Comments
 (0)