@BackSeat contributed the patch. Signature changes are mentioned in README.
This commit is contained in:
Ian Cordasco 2012-11-08 09:03:54 -05:00
parent cc1d7c5385
commit 82ea7edadc
4 changed files with 14 additions and 9 deletions

5
README
View file

@ -223,8 +223,11 @@ CHANGES
=======
1.6
---
XXX
- changed the signatures of the ``check_file`` function in flake8/run.py,
``skip_warning`` in flake8/util.py and the ``check``, ``checkPath``
functions in flake8/pyflakes.py.
1.5 - 2012-10-13

View file

@ -649,21 +649,21 @@ class Checker(object):
self.addBinding(node.lineno, importation)
def checkPath(filename):
def checkPath(filename, ignore=[]):
"""
Check the given path, printing out any warnings detected.
@return: the number of warnings printed
"""
try:
return check(open(filename, 'U').read() + '\n', filename)
return check(open(filename, 'U').read() + '\n', ignore, filename)
except IOError:
msg = sys.exc_info()[1]
sys.stderr.write("%s: %s\n" % (filename, msg.args[1]))
return 1
def check(codeString, filename='(code)'):
def check(codeString, ignore, filename='(code)'):
"""
Check the Python source given by C{codeString} for flakes.
@ -714,7 +714,7 @@ def check(codeString, filename='(code)'):
valid_warnings = 0
for warning in w.messages:
if skip_warning(warning):
if skip_warning(warning, ignore):
continue
print(warning)
valid_warnings += 1

View file

@ -20,10 +20,10 @@ from flake8 import mccabe
pep8style = None
def check_file(path, complexity=-1):
def check_file(path, ignore=[], complexity=-1):
if pep8style.excluded(path):
return 0
warnings = pyflakes.checkPath(path)
warnings = pyflakes.checkPath(path, ignore)
warnings += pep8style.input_file(path)
if complexity > -1:
warnings += mccabe.get_module_complexity(path, complexity)
@ -68,7 +68,7 @@ def main():
if pep8style.paths and options.filename is not None:
for path in _get_python_files(pep8style.paths):
warnings += check_file(path, complexity)
warnings += check_file(path, options.ignore, complexity)
else:
# wait for 1 second on the stdin fd
reads, __, __ = select.select([sys.stdin], [], [], 1.)

View file

@ -3,8 +3,10 @@ import re
import os
def skip_warning(warning):
def skip_warning(warning, ignore=[]):
# XXX quick dirty hack, just need to keep the line in the warning
if warning.message.split()[0] in ignore:
return True
if not os.path.isfile(warning.filename):
return False