python: Apply Black formatter to Python files

The command executed was `black src configs tests util`.

Change-Id: I8dfaa6ab04658fea37618127d6ac19270028d771
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/47024
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Bobby R. Bruce
2022-07-05 11:02:25 -07:00
committed by Giacomo Travaglini
parent 1cfaa8da83
commit 787204c92d
980 changed files with 35668 additions and 22233 deletions

View File

@@ -36,7 +36,6 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from tempfile import TemporaryFile
import os
import subprocess
@@ -48,11 +47,11 @@ from style.style import StdioUI, check_ignores
import argparse
parser = argparse.ArgumentParser(
description="gem5 git style checker hook")
parser = argparse.ArgumentParser(description="gem5 git style checker hook")
parser.add_argument("--verbose", "-v", action="store_true",
help="Produce verbose output")
parser.add_argument(
"--verbose", "-v", action="store_true", help="Produce verbose output"
)
args = parser.parse_args()
@@ -80,16 +79,22 @@ for status, fname in git.status(filter="MA", cached=True):
try:
status = git.file_from_index(fname)
except UnicodeDecodeError:
print("Decoding '" + fname
+ "' throws a UnicodeDecodeError.", file=sys.stderr)
print("Please check '" + fname
+ "' exclusively uses utf-8 character encoding.", file=sys.stderr)
print(
"Decoding '" + fname + "' throws a UnicodeDecodeError.",
file=sys.stderr,
)
print(
"Please check '"
+ fname
+ "' exclusively uses utf-8 character encoding.",
file=sys.stderr,
)
sys.exit(1)
f = TemporaryFile()
f.write(status.encode('utf-8'))
f.write(status.encode("utf-8"))
verifiers = [ v(ui, opts, base=repo_base) for v in all_verifiers ]
verifiers = [v(ui, opts, base=repo_base) for v in all_verifiers]
for v in verifiers:
f.seek(0)
# It is prefered that the first check is silent as it is in the
@@ -113,14 +118,17 @@ if failing_files:
"Please run the style checker manually to fix "
"the offending files.\n"
"To check your modifications, run: util/style.py -m",
file=sys.stderr)
file=sys.stderr,
)
print("\n", file=sys.stderr)
if staged_mismatch:
print(
"It looks like you have forgotten to stage your "
"fixes for commit in\n"
"the following files: ", file=sys.stderr)
"the following files: ",
file=sys.stderr,
)
for f in staged_mismatch:
print("\t{}".format(f), file=sys.stderr)
print("Please `git --add' them", file=sys.stderr)