[go: up one dir, main page]

File: run_mypy.py

package info (click to toggle)
uranium 3.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,876 kB
  • sloc: python: 22,349; sh: 111; makefile: 11
file content (36 lines) | stat: -rw-r--r-- 1,018 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!env python
import os
import sys
import subprocess

# 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 main():
    if sys.platform == "win32":
        os.putenv("MYPYPATH", r".;.\stubs")
    else:
        os.putenv("MYPYPATH", r".:./stubs")

    # 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")

    result = subprocess.run([sys.executable, mypyModule, "-p", "UM"])
    if result.returncode != 0:
        print("Type checking failed.")
    else:
        print("""

    Done checking. All is good.
    """)

    return 0
sys.exit(main())