mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 03:37:48 -06:00
Speed up mypy checking
Checking Cura takes up most of the time, but during that time we could check for the plugins.
This commit is contained in:
parent
0862fd493e
commit
e28a662d7c
1 changed files with 19 additions and 16 deletions
29
run_mypy.py
29
run_mypy.py
|
@ -1,8 +1,9 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
from multiprocessing.dummy import Pool
|
||||||
|
from functools import partial
|
||||||
|
from subprocess import call
|
||||||
|
|
||||||
# A quick Python implementation of unix 'where' command.
|
# A quick Python implementation of unix 'where' command.
|
||||||
def where(exe_name: str, search_path: str = os.getenv("PATH")) -> str:
|
def where(exe_name: str, search_path: str = os.getenv("PATH")) -> str:
|
||||||
|
@ -62,21 +63,23 @@ def main():
|
||||||
|
|
||||||
mods = ["cura"] + plugins + findModules("plugins/VersionUpgrade")
|
mods = ["cura"] + plugins + findModules("plugins/VersionUpgrade")
|
||||||
success_code = 0
|
success_code = 0
|
||||||
for mod in mods:
|
|
||||||
print("------------- Checking module {mod}".format(**locals()))
|
pool = Pool(2) # Run two commands at once
|
||||||
if sys.platform == "win32":
|
|
||||||
result = subprocess.run([mypy_module, "-p", mod, "--ignore-missing-imports"])
|
if sys.platform == "win32":
|
||||||
else:
|
commands = ["%s -p %s --ignore-missing-imports" % (mypy_module, mod) for mod in mods]
|
||||||
result = subprocess.run([sys.executable, mypy_module, "-p", mod, "--ignore-missing-imports"])
|
else:
|
||||||
if result.returncode != 0:
|
commands = ["%s %s -p %s --ignore-missing-imports" % (sys.executable, mypy_module, mod) for mod in mods]
|
||||||
print("\nModule {mod} failed checking. :(".format(**locals()))
|
|
||||||
|
for i, returncode in enumerate(pool.imap(partial(call, shell=True), commands)):
|
||||||
|
if returncode != 0:
|
||||||
|
print("\nCommand %s failed checking. :(" % commands[i])
|
||||||
success_code = 1
|
success_code = 1
|
||||||
if success_code:
|
if success_code:
|
||||||
print("\n\nSome modules failed checking!")
|
print("MYPY check was compleded, but did not pass")
|
||||||
else:
|
else:
|
||||||
print("\n\nDone checking. All is good.")
|
print("MYPY check was compleded and passed with flying colors")
|
||||||
return success_code
|
return success_code
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main())
|
sys.exit(main())
|
Loading…
Add table
Add a link
Reference in a new issue