Browse Source

Tools: Improved flake8 speed, ignore, and exclude

apm_2208
TunaLobster 3 years ago committed by Peter Barker
parent
commit
e77ab54de1
  1. 7
      .flake8
  2. 17
      Tools/scripts/run_flake8.py

7
.flake8

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
[flake8]
ignore =
extend-ignore =
# H301: one import per line
H301,
# H306: imports not in alphabetical order (time, os)
@ -15,4 +15,9 @@ ignore = @@ -15,4 +15,9 @@ ignore =
# E221 multiple spaces before operator
E221
extend-exclude =
build,
modules,
.git
max-line-length = 127

17
Tools/scripts/run_flake8.py

@ -19,16 +19,18 @@ os.environ['PYTHONUNBUFFERED'] = '1' @@ -19,16 +19,18 @@ os.environ['PYTHONUNBUFFERED'] = '1'
class Flake8Checker(object):
def __init__(self):
self.retcode = 0
self.files_to_check = []
def progress(self, string):
print("****** %s" % (string,))
def check(self, filepath):
self.progress("Checking (%s)" % filepath)
retcode = subprocess.call(["flake8", filepath])
if retcode != 0:
self.progress("File (%s) failed with retcode (%s)" %
(filepath, retcode))
def check(self):
for path in self.files_to_check:
self.progress("Checking (%s)" % path)
ret = subprocess.run(["flake8", "--show-source"] + self.files_to_check,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
if ret.returncode != 0:
self.progress("Flake8 check failed: (%s)" % (ret.stdout))
self.retcode = 1
def run(self):
@ -40,7 +42,8 @@ class Flake8Checker(object): @@ -40,7 +42,8 @@ class Flake8Checker(object):
content = open(filepath).read()
if "AP_FLAKE8_CLEAN" not in content:
continue
self.check(filepath)
self.files_to_check.append(filepath)
self.check()
return self.retcode

Loading…
Cancel
Save