mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-29 10:36:53 +00:00
make sure flake8 is clean
This commit is contained in:
parent
fc026a5e8a
commit
ff8a99cd62
5 changed files with 17 additions and 10 deletions
|
|
@ -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__':
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue