Skip to content

Commit f5980ce

Browse files
zaniebindygreg
authored andcommitted
Display commands on check
1 parent 4397859 commit f5980ce

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

check.py

+26-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# License, v. 2.0. If a copy of the MPL was not distributed with this
44
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
55

6+
from __future__ import annotations
7+
68
import argparse
79
import os
810
import pathlib
@@ -31,6 +33,15 @@ def bootstrap():
3133
os.execv(str(PYTHON), args)
3234

3335

36+
def run_command(command: list[str]) -> int:
37+
print("$ " + " ".join(command))
38+
returncode = subprocess.run(
39+
command, stdout=sys.stdout, stderr=sys.stderr
40+
).returncode
41+
print()
42+
return returncode
43+
44+
3445
def run():
3546
env = dict(os.environ)
3647
env["PYTHONUNBUFFERED"] = "1"
@@ -49,26 +60,28 @@ def run():
4960
# Unused variable
5061
check_args = ["--select", "I,F401,F841"]
5162
format_args = []
52-
mypy_args = ["pythonbuild"]
63+
mypy_args = [
64+
"pythonbuild",
65+
"check.py",
66+
"build-linux.py",
67+
"build-macos.py",
68+
"build-windows.py",
69+
]
5370

5471
if args.fix:
5572
check_args.append("--fix")
5673
else:
5774
format_args.append("--check")
5875

59-
check_result = subprocess.run(
60-
["ruff", "check"] + check_args, stdout=sys.stdout, stderr=sys.stderr
61-
)
62-
format_result = subprocess.run(
63-
["ruff", "format"] + format_args, stdout=sys.stdout, stderr=sys.stderr
64-
)
65-
mypy_result = subprocess.run(
66-
["mypy"] + mypy_args, stdout=sys.stdout, stderr=sys.stderr
67-
)
76+
check_result = run_command(["ruff", "check"] + check_args)
77+
format_result = run_command(["ruff", "format"] + format_args)
78+
mypy_result = run_command(["mypy"] + mypy_args)
6879

69-
sys.exit(
70-
check_result.returncode + format_result.returncode + mypy_result.returncode
71-
)
80+
if check_result + format_result + mypy_result:
81+
print("Checks failed!")
82+
sys.exit(1)
83+
else:
84+
print("Checks passed!")
7285

7386

7487
if __name__ == "__main__":

0 commit comments

Comments
 (0)