forked from AtsushiSakai/PythonRobotics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mypy_type_check.py
More file actions
50 lines (40 loc) · 1.06 KB
/
test_mypy_type_check.py
File metadata and controls
50 lines (40 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import subprocess
import conftest
SUBPACKAGE_LIST = [
"AerialNavigation",
"ArmNavigation",
"Bipedal",
"Localization",
"Mapping",
"PathPlanning",
"PathTracking",
"SLAM",
"InvertedPendulum"
]
def run_mypy(dir_name, project_path, config_path):
res = subprocess.run(
['mypy',
'--config-file',
config_path,
'-p',
dir_name],
cwd=project_path,
stdout=subprocess.PIPE,
encoding='utf-8')
return res.returncode, res.stdout
def test():
project_dir_path = os.path.dirname(
os.path.dirname(os.path.abspath(__file__)))
print(f"{project_dir_path=}")
config_path = os.path.join(project_dir_path, "mypy.ini")
print(f"{config_path=}")
for sub_package_name in SUBPACKAGE_LIST:
rc, errors = run_mypy(sub_package_name, project_dir_path, config_path)
if errors:
print(errors)
else:
print("No lint errors found.")
assert rc == 0
if __name__ == '__main__':
conftest.run_this_test(__file__)