From e77ab54de1451321765afe6e00889598bdd9c6f3 Mon Sep 17 00:00:00 2001 From: TunaLobster Date: Fri, 24 Jun 2022 14:55:35 -0500 Subject: [PATCH] Tools: Improved flake8 speed, ignore, and exclude --- .flake8 | 7 ++++++- Tools/scripts/run_flake8.py | 17 ++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.flake8 b/.flake8 index 1f3da2e2bd..2c66c08aed 100644 --- a/.flake8 +++ b/.flake8 @@ -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 = # E221 multiple spaces before operator E221 +extend-exclude = + build, + modules, + .git + max-line-length = 127 diff --git a/Tools/scripts/run_flake8.py b/Tools/scripts/run_flake8.py index 695f86f014..acfde4e4e5 100755 --- a/Tools/scripts/run_flake8.py +++ b/Tools/scripts/run_flake8.py @@ -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): 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