mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 10:46:54 +00:00
Fixes #69
Note to self: I also have to make sure the VCS hooks work with the new pyflakes API.
This commit is contained in:
parent
10cc0f3391
commit
064f986d9a
2 changed files with 5 additions and 1 deletions
|
|
@ -65,13 +65,14 @@ def main():
|
|||
if opts.exit_zero:
|
||||
raise SystemExit(0)
|
||||
|
||||
raise SystemExit(warnings)
|
||||
raise SystemExit(warnings > 0)
|
||||
|
||||
|
||||
def check_file(path, ignore=(), complexity=-1, reporter=None):
|
||||
if pep8style.excluded(path):
|
||||
return 0
|
||||
warnings = pyflakes.api.checkPath(path, reporter)
|
||||
warnings -= reporter.ignored_warnings
|
||||
warnings += pep8style.input_file(path)
|
||||
if complexity > -1:
|
||||
warnings += mccabe.get_module_complexity(path, complexity)
|
||||
|
|
@ -80,6 +81,7 @@ def check_file(path, ignore=(), complexity=-1, reporter=None):
|
|||
|
||||
def check_code(code, ignore=(), complexity=-1, reporter=None):
|
||||
warnings = pyflakes.api.check(code, '<stdin>', reporter)
|
||||
warnings -= reporter.ignored_warnings
|
||||
warnings += pep8style.input_file('-', lines=code.split('\n'))
|
||||
if complexity > -1:
|
||||
warnings += mccabe.get_code_complexity(code, complexity)
|
||||
|
|
|
|||
|
|
@ -137,12 +137,14 @@ class Flake8Reporter(reporter.Reporter):
|
|||
def __init__(self, ignore=None):
|
||||
super(Flake8Reporter, self).__init__(sys.stdout, sys.stderr)
|
||||
self.ignore = ignore or []
|
||||
self.ignored_warnings = 0
|
||||
|
||||
def flake(self, message):
|
||||
classes = [error_mapping[i] for i in self.ignore if i in error_mapping]
|
||||
|
||||
if (any(isinstance(message, c) for c in classes) or
|
||||
skip_warning(message)):
|
||||
self.ignored_warnings += 1
|
||||
return
|
||||
m = self.to_str(message)
|
||||
i = m.rfind(':') + 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue