Files
typeshed/tests/mypy_selftest.py
Sebastian Rittau 0583738a41 Add a mypy self test (#4337)
Co-authored-by: Shantanu <hauntsaninja@users.noreply.github.com>
Co-authored-by: hauntsaninja <>
2020-10-24 17:58:04 -07:00

40 lines
1.3 KiB
Python
Executable File

#!/usr/bin/env python3
"""Script to run mypy against its own code base."""
from pathlib import Path
import subprocess
import sys
import tempfile
MYPY_VERSION = "0.790"
if __name__ == "__main__":
with tempfile.TemporaryDirectory() as tempdir:
dirpath = Path(tempdir)
subprocess.run(
["git", "clone", "--depth", "1", "git://github.com/python/mypy", str(dirpath)],
check=True,
)
try:
subprocess.run([sys.executable, "-m", "pip", "install", f"mypy=={MYPY_VERSION}"], check=True)
subprocess.run([sys.executable, "-m", "pip", "install", "-r", dirpath / "test-requirements.txt"], check=True)
subprocess.run(
[
"mypy",
"--config-file",
dirpath / "mypy_self_check.ini",
"--custom-typeshed-dir",
".",
dirpath / "mypy",
dirpath / "mypyc",
],
check=True,
)
except subprocess.CalledProcessError as e:
print("mypy self test failed", file=sys.stderr)
sys.exit(e.returncode)
else:
print("mypy self test succeeded", file=sys.stderr)
sys.exit(0)