2
0

run_mypy.py 701 B

12345678910111213141516171819202122232425262728
  1. import pathlib
  2. import shutil
  3. import subprocess
  4. import sys
  5. import tempfile
  6. def main():
  7. root = pathlib.Path(__file__).parent.parent
  8. direct_src = root / 'direct' / 'src'
  9. mypy_config = root / 'mypy.ini'
  10. with tempfile.TemporaryDirectory() as temp_dir:
  11. direct_copy = pathlib.Path(temp_dir, 'direct')
  12. shutil.copytree(direct_src, direct_copy)
  13. command = [
  14. sys.executable,
  15. '-m',
  16. 'mypy',
  17. str(direct_copy.resolve()),
  18. '--config-file',
  19. str(mypy_config.resolve()),
  20. ]
  21. result = subprocess.run(command, cwd=temp_dir)
  22. sys.exit(result.returncode)
  23. if __name__ == '__main__':
  24. main()