Local configuration files are ignored if parse_argv is False#246
Local configuration files are ignored if parse_argv is False#246kynan wants to merge 1 commit intoPyCQA:masterfrom kynan:246-enable-local-configuration-file-parsing
parse_argv is False#246Conversation
When used as a library, set args in process_options to current directory to enable parsing of local configuration files.
|
For some background: The problem is illustrated by https://bitbucket.org/tarek/flake8/commits/d325cf7e7f4df3efe650dd7b26c8338d452fca53, a change I made to flake8 to allow the Git and Mercurial hooks to parse local configuration files, but which breaks if no configuration files are present. Unfortunately it is not possible to make this work for both cases without this change to pep8. |
|
Any thoughts on this? |
|
flake8 is dependent on this change @florentx |
|
Some more explanation: Not specifying |
|
In order to preserve backward compatibility, I would accept an additional keyword argument diff --git a/pep8.py b/pep8.py
index e38ab26..71aaf19 100755
--- a/pep8.py
+++ b/pep8.py
@@ -1571,11 +1571,12 @@ class StyleGuide(object):
def __init__(self, *args, **kwargs):
# build options from the command line
self.checker_class = kwargs.pop('checker_class', Checker)
+ arglist = kwargs.pop('arglist', None)
parse_argv = kwargs.pop('parse_argv', False)
config_file = kwargs.pop('config_file', None)
parser = kwargs.pop('parser', None)
- options, self.paths = process_options(
- parse_argv=parse_argv, config_file=config_file, parser=parser)
+ (options, self.paths) = process_options(
+ arglist, parse_argv, config_file, parser)
if args or kwargs:
# build options from dict
options_dict = dict(*args, **kwargs)It will be available in the flake8_style = get_style_guide(
arglist=['.'],
config_file=DEFAULT_CONFIG,
**options) |
|
OK, that would work for flake8. I'll send a pull request. |
|
Done: #259 |
|
The other PR is merged |
|
On second thought, I see the argument |
|
This should probably be better documented then. :) |
|
@florentx I agree, using |
When using
pep8as a library, there is currently no way to make theStyleGuideread local configuration files (tox.ini,setup.cfg) other than passingparse_argv=True. This makes little sense in library use wheresys.argvis empty, since it breaks for the case where no local configuration files exist with "input not specified".