@@ -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):
18171817def 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
0 commit comments