3
3
# License, v. 2.0. If a copy of the MPL was not distributed with this
4
4
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
5
6
+ from __future__ import annotations
7
+
6
8
import argparse
7
9
import os
8
10
import pathlib
@@ -31,6 +33,15 @@ def bootstrap():
31
33
os .execv (str (PYTHON ), args )
32
34
33
35
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
+
34
45
def run ():
35
46
env = dict (os .environ )
36
47
env ["PYTHONUNBUFFERED" ] = "1"
@@ -49,26 +60,28 @@ def run():
49
60
# Unused variable
50
61
check_args = ["--select" , "I,F401,F841" ]
51
62
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
+ ]
53
70
54
71
if args .fix :
55
72
check_args .append ("--fix" )
56
73
else :
57
74
format_args .append ("--check" )
58
75
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 )
68
79
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!" )
72
85
73
86
74
87
if __name__ == "__main__" :
0 commit comments