diff --git a/cura/LayerPolygon.py b/cura/LayerPolygon.py index 70b17cff75..81fe66a80d 100644 --- a/cura/LayerPolygon.py +++ b/cura/LayerPolygon.py @@ -1,6 +1,6 @@ from UM.Math.Color import Color from UM.Application import Application - +from typing import Any import numpy @@ -173,7 +173,7 @@ class LayerPolygon: return normals - __color_map = None + __color_map = None # type: numpy.ndarray[Any] ## Gets the instance of the VersionUpgradeManager, or creates one. @classmethod diff --git a/run_mypy.py b/run_mypy.py index c5dfb23802..24c9d3ae31 100644 --- a/run_mypy.py +++ b/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())