Skip to content

Commit

Permalink
Fixed one new class variable. Updated the script to run mypy.
Browse files Browse the repository at this point in the history
  • Loading branch information
sedwards2009 committed Feb 1, 2017
1 parent eb43806 commit 4715afd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
4 changes: 2 additions & 2 deletions cura/LayerPolygon.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from UM.Math.Color import Color
from UM.Application import Application

from typing import Any
import numpy


Expand Down Expand Up @@ -173,7 +173,7 @@ def getNormals(self):

return normals

__color_map = None
__color_map = None # type: numpy.ndarray[Any]

## Gets the instance of the VersionUpgradeManager, or creates one.
@classmethod
Expand Down
50 changes: 34 additions & 16 deletions run_mypy.py
Original file line number Diff line number Diff line change
@@ -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 = []
Expand All @@ -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())

0 comments on commit 4715afd

Please sign in to comment.