mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-15 16:49:52 +00:00
I was wrong. Forgot a couple lines
This commit is contained in:
parent
5342830f80
commit
c9a5923a46
1 changed files with 2 additions and 45 deletions
|
|
@ -104,7 +104,7 @@ def main():
|
||||||
|
|
||||||
pep8style = pep8.StyleGuide(parse_argv=True, config_file=True)
|
pep8style = pep8.StyleGuide(parse_argv=True, config_file=True)
|
||||||
options = pep8style.options
|
options = pep8style.options
|
||||||
complexity = options.max_complexity
|
complexity = opts.max_complexity
|
||||||
builtins = set(opts.builtins.split(','))
|
builtins = set(opts.builtins.split(','))
|
||||||
warnings = 0
|
warnings = 0
|
||||||
stdin = None
|
stdin = None
|
||||||
|
|
@ -125,7 +125,7 @@ def main():
|
||||||
stdin = read_stdin()
|
stdin = read_stdin()
|
||||||
warnings += check_code(stdin, opts.ignore, complexity)
|
warnings += check_code(stdin, opts.ignore, complexity)
|
||||||
|
|
||||||
if options.exit_zero:
|
if opts.exit_zero:
|
||||||
raise SystemExit(0)
|
raise SystemExit(0)
|
||||||
|
|
||||||
raise SystemExit(warnings)
|
raise SystemExit(warnings)
|
||||||
|
|
@ -186,49 +186,6 @@ def run(command):
|
||||||
[line.strip() for line in p.stderr.readlines()])
|
[line.strip() for line in p.stderr.readlines()])
|
||||||
|
|
||||||
|
|
||||||
def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
|
|
||||||
_initpep8()
|
|
||||||
if ignore:
|
|
||||||
pep8style.options.ignore = ignore
|
|
||||||
|
|
||||||
warnings = 0
|
|
||||||
|
|
||||||
gitcmd = "git diff-index --cached --name-only HEAD"
|
|
||||||
if lazy:
|
|
||||||
gitcmd = gitcmd.replace('--cached ', '')
|
|
||||||
|
|
||||||
_, files_modified, _ = run(gitcmd)
|
|
||||||
for filename in files_modified:
|
|
||||||
ext = os.path.splitext(filename)[-1]
|
|
||||||
if ext != '.py':
|
|
||||||
continue
|
|
||||||
if not os.path.exists(filename):
|
|
||||||
continue
|
|
||||||
warnings += check_file(path=filename, ignore=ignore,
|
|
||||||
complexity=complexity)
|
|
||||||
|
|
||||||
if strict:
|
|
||||||
return warnings
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def hg_hook(ui, repo, **kwargs):
|
|
||||||
_initpep8()
|
|
||||||
complexity = ui.config('flake8', 'complexity', default=-1)
|
|
||||||
warnings = 0
|
|
||||||
|
|
||||||
for file_ in _get_files(repo, **kwargs):
|
|
||||||
warnings += check_file(file_, complexity)
|
|
||||||
|
|
||||||
strict = ui.configbool('flake8', 'strict', default=True)
|
|
||||||
|
|
||||||
if strict:
|
|
||||||
return warnings
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from setuptools import Command
|
from setuptools import Command
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue