mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-06 05:23:58 -06:00
Fixed one new class variable. Updated the script to run mypy.
This commit is contained in:
parent
eb43806d7a
commit
4715afdad6
2 changed files with 35 additions and 17 deletions
48
run_mypy.py
48
run_mypy.py
|
@ -1,8 +1,17 @@
|
|||
#!env python
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
os.putenv("MYPYPATH", r".;.\plugins;.\plugins\VersionUpgrade;..\Uranium_hint\;..\Uranium_hint\stubs\\" )
|
||||
# A quick Python implementation of unix 'where' command.
|
||||
def where(exeName):
|
||||
searchPath = os.getenv("PATH")
|
||||
paths = searchPath.split(";" if sys.platform == "win32" else ":")
|
||||
for path in paths:
|
||||
candidatePath = os.path.join(path, exeName)
|
||||
if os.path.exists(candidatePath):
|
||||
return candidatePath
|
||||
return None
|
||||
|
||||
def findModules(path):
|
||||
result = []
|
||||
|
@ -11,21 +20,30 @@ def findModules(path):
|
|||
result.append(entry.name)
|
||||
return result
|
||||
|
||||
plugins = findModules("plugins")
|
||||
plugins.sort()
|
||||
def main():
|
||||
os.putenv("MYPYPATH", r".;.\plugins;.\plugins\VersionUpgrade;..\Uranium_hint\;..\Uranium_hint\stubs\\" )
|
||||
|
||||
mods = ["cura"] + plugins + findModules("plugins/VersionUpgrade")
|
||||
# Mypy really needs to be run via its Python script otherwise it can't find its data files.
|
||||
mypyExe = where("mypy.bat" if sys.platform == "win32" else "mypy")
|
||||
mypyModule = os.path.join(os.path.dirname(mypyExe), "mypy")
|
||||
|
||||
for mod in mods:
|
||||
print("------------- Checking module {mod}".format(**locals()))
|
||||
result = subprocess.run(["python", r"c:\python35\Scripts\mypy", "-p", mod])
|
||||
if result.returncode != 0:
|
||||
plugins = findModules("plugins")
|
||||
plugins.sort()
|
||||
|
||||
mods = ["cura"] + plugins + findModules("plugins/VersionUpgrade")
|
||||
|
||||
for mod in mods:
|
||||
print("------------- Checking module {mod}".format(**locals()))
|
||||
result = subprocess.run([sys.executable, mypyModule, "-p", mod])
|
||||
if result.returncode != 0:
|
||||
print("""
|
||||
Module {mod} failed checking. :(
|
||||
""".format(**locals()))
|
||||
break
|
||||
else:
|
||||
print("""
|
||||
Module {mod} failed checking. :(
|
||||
""".format(**locals()))
|
||||
break
|
||||
else:
|
||||
print("""
|
||||
|
||||
Done checking. All is good.
|
||||
""")
|
||||
Done checking. All is good.
|
||||
""")
|
||||
return 0
|
||||
sys.exit(main())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue