Skip to content

Commit 68d72a5

Browse files
committed
Revert previous change and fix the 'paths' keyword argument instead; fixes #246
1 parent f2dbcb7 commit 68d72a5

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Changelog
1212

1313
* Fix regression with multiple brackets. (Issue #214)
1414

15+
* Fix ``StyleGuide`` to parse the local configuration if the
16+
keyword argument ``paths`` is specified. (Issue #246)
17+
1518

1619
1.4.6 (2013-07-02)
1720
------------------

pep8.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,15 +1574,15 @@ class StyleGuide(object):
15741574
def __init__(self, *args, **kwargs):
15751575
# build options from the command line
15761576
self.checker_class = kwargs.pop('checker_class', Checker)
1577-
arglist = kwargs.pop('arglist', None)
15781577
parse_argv = kwargs.pop('parse_argv', False)
15791578
config_file = kwargs.pop('config_file', None)
15801579
parser = kwargs.pop('parser', None)
1580+
# build options from dict
1581+
options_dict = dict(*args, **kwargs)
1582+
arglist = None if parse_argv else options_dict.get('paths', None)
15811583
options, self.paths = process_options(
15821584
arglist, parse_argv, config_file, parser)
1583-
if args or kwargs:
1584-
# build options from dict
1585-
options_dict = dict(*args, **kwargs)
1585+
if options_dict:
15861586
options.__dict__.update(options_dict)
15871587
if 'paths' in options_dict:
15881588
self.paths = options_dict['paths']
@@ -1817,9 +1817,6 @@ def read_config(options, args, arglist, parser):
18171817
def process_options(arglist=None, parse_argv=False, config_file=None,
18181818
parser=None):
18191819
"""Process options passed either via arglist or via command line args."""
1820-
if not arglist and not parse_argv:
1821-
# Don't read the command line if the module is used as a library.
1822-
arglist = []
18231820
if not parser:
18241821
parser = get_parser()
18251822
if not parser.has_option('--config'):
@@ -1832,7 +1829,11 @@ def process_options(arglist=None, parse_argv=False, config_file=None,
18321829
(parser.prog, ', '.join(parser.config_options))))
18331830
group.add_option('--config', metavar='path', default=config_file,
18341831
help="user config file location (default: %default)")
1835-
# If parse_argv is None, the arguments are parsed from sys.argv
1832+
# Don't read the command line if the module is used as a library.
1833+
if not arglist and not parse_argv:
1834+
arglist = []
1835+
# If parse_argv is True and arglist is None, arguments are
1836+
# parsed from the command line (sys.argv)
18361837
(options, args) = parser.parse_args(arglist)
18371838
options.reporter = None
18381839

testsuite/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_styleguide_options(self):
164164
self.assertEqual(pep8style.options.filename, ['*.py'])
165165
self.assertEqual(pep8style.options.format, 'default')
166166
self.assertEqual(pep8style.options.select, ())
167-
self.assertEqual(pep8style.options.ignore, ('E123', 'E226', 'E24'))
167+
self.assertEqual(pep8style.options.ignore, ('E226', 'E24'))
168168
self.assertEqual(pep8style.options.max_line_length, 79)
169169

170170
def test_styleguide_ignore_code(self):

0 commit comments

Comments
 (0)