Fixed one new class variable. Updated the script to run mypy.

This commit is contained in:
Simon Edwards 2017-02-01 14:53:22 +01:00
parent eb43806d7a
commit 4715afdad6
2 changed files with 35 additions and 17 deletions

View File

@ -1,6 +1,6 @@
from UM.Math.Color import Color from UM.Math.Color import Color
from UM.Application import Application from UM.Application import Application
from typing import Any
import numpy import numpy
@ -173,7 +173,7 @@ class LayerPolygon:
return normals return normals
__color_map = None __color_map = None # type: numpy.ndarray[Any]
## Gets the instance of the VersionUpgradeManager, or creates one. ## Gets the instance of the VersionUpgradeManager, or creates one.
@classmethod @classmethod

View File

@ -1,8 +1,17 @@
#!env python #!env python
import os import os
import sys
import subprocess 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): def findModules(path):
result = [] result = []
@ -11,21 +20,30 @@ def findModules(path):
result.append(entry.name) result.append(entry.name)
return result return result
plugins = findModules("plugins") def main():
plugins.sort() 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: plugins = findModules("plugins")
print("------------- Checking module {mod}".format(**locals())) plugins.sort()
result = subprocess.run(["python", r"c:\python35\Scripts\mypy", "-p", mod])
if result.returncode != 0: 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(""" 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())