diff --git a/bin/flake8 b/bin/flake8 index 2001e00..f2166f8 100755 --- a/bin/flake8 +++ b/bin/flake8 @@ -1,4 +1,4 @@ -#!/home/tarek/dev/bitbucket.org/flake8-clean/bin/python +#!/home/tarek/dev/bitbucket.org/flk8/bin/python from flake8.run import main if __name__ == '__main__': diff --git a/flake8/mccabe.py b/flake8/mccabe.py index 9491fdd..87405d4 100644 --- a/flake8/mccabe.py +++ b/flake8/mccabe.py @@ -3,8 +3,9 @@ http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html MIT License. """ - -import compiler, optparse, sys +import compiler +import optparse +import sys class PathNode: @@ -13,7 +14,8 @@ class PathNode: self.look = look def to_dot(self): - print 'node [shape=%s,label="%s"] %d;' % (self.look, self.name, self.dot_id()) + print 'node [shape=%s,label="%s"] %d;' % \ + (self.look, self.name, self.dot_id()) def dot_id(self): return id(self) @@ -204,12 +206,15 @@ def get_module_complexity(module_path, min=7): def main(argv): opar = optparse.OptionParser() - opar.add_option("-d", "--dot", dest="dot", help="output a graphviz dot file", action="store_true") - opar.add_option("-m", "--min", dest="min", help="minimum complexity for output", type="int", default=2) + opar.add_option("-d", "--dot", dest="dot", + help="output a graphviz dot file", action="store_true") + opar.add_option("-m", "--min", dest="min", + help="minimum complexity for output", type="int", + default=2) options, args = opar.parse_args(argv) - text = open(args[0], "rU").read()+'\n\n' + text = open(args[0], "rU").read() + '\n\n' ast = compiler.parse(text) visitor = PathGraphingAstVisitor() visitor.preorder(ast, visitor) diff --git a/flake8/pep8.py b/flake8/pep8.py index 8d98441..a6372d8 100644 --- a/flake8/pep8.py +++ b/flake8/pep8.py @@ -727,7 +727,7 @@ else: # Python 3: decode to latin-1. # This function is lazy, it does not read the encoding declaration. # XXX: use tokenize.detect_encoding() - def readlines(filename): + def readlines(filename): # NOQA return open(filename, encoding='latin-1').readlines() diff --git a/flake8/pyflakes.py b/flake8/pyflakes.py index a201a06..16ec1a4 100644 --- a/flake8/pyflakes.py +++ b/flake8/pyflakes.py @@ -619,6 +619,7 @@ class Checker(object): importation.used = (self.scope, node.lineno) self.addBinding(node.lineno, importation) + def checkPath(filename): """ Check the given path, printing out any warnings detected. @@ -631,6 +632,7 @@ def checkPath(filename): print >> sys.stderr, "%s: %s" % (filename, msg.args[1]) return 1 + def check(codeString, filename): """ Check the Python source given by C{codeString} for flakes. @@ -685,4 +687,3 @@ def check(codeString, filename): valid_warnings += 1 return valid_warnings - diff --git a/flake8/util.py b/flake8/util.py index 87a340e..42f15d8 100644 --- a/flake8/util.py +++ b/flake8/util.py @@ -3,9 +3,10 @@ import re def skip_warning(warning): # XXX quick dirty hack, just need to keep the line in the warning - line = open(warning.filename).readlines()[warning.lineno-1] + line = open(warning.filename).readlines()[warning.lineno - 1] return skip_line(line) + def skip_line(line): return line.strip().lower().endswith('# noqa')