From a4ebc1c5c423cf68b9cd304468af05df05ba061d Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Wed, 7 Nov 2012 12:40:49 -0500 Subject: [PATCH] Fix #21. ``init`` can also be used elsewhere. Sane defaults are awesome. Also, I hope mercurial uses similar commit messages to git. ;) --- flake8/run.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/flake8/run.py b/flake8/run.py index 3687251..ee77a59 100644 --- a/flake8/run.py +++ b/flake8/run.py @@ -54,9 +54,14 @@ def _get_python_files(paths): yield path -def main(): +def init(parse_argv=False, config_file=True, **kwargs): global pep8style - pep8style = pep8.StyleGuide(parse_argv=True, config_file=True) + pep8style = pep8.StyleGuide(parse_argv=parse_argv, + config_file=config_file) + + +def main(): + init(True) options = pep8style.options complexity = options.max_complexity builtins = set(options.builtins) @@ -138,9 +143,7 @@ def run(command): def git_hook(complexity=-1, strict=False, ignore=None): - global pep8style - pep8style = pep8.StyleGuide(config_file=True) - + init() _initpep8() if ignore: pep8.options.ignore = ignore @@ -203,8 +206,7 @@ else: yield "%s.py" % filename def run(self): - global pep8style - pep8style = pep8.StyleGuide(config_file=True) + init() _initpep8()