mypy_without_ignores.py 664 B

12345678910111213141516171819202122232425
  1. from __future__ import annotations
  2. import os.path
  3. import subprocess
  4. import sys
  5. import tempfile
  6. def main() -> int:
  7. with open("pyproject.toml") as f:
  8. src = f.read()
  9. msg = "sentry modules with typing issues"
  10. before, begin, rest = src.partition(f"# begin: {msg}\n")
  11. _, end, rest = rest.partition(f"# end: {msg}\n")
  12. with tempfile.TemporaryDirectory() as tmpdir:
  13. cfg = os.path.join(tmpdir, "mypy.toml")
  14. with open(cfg, "w") as f:
  15. f.write(before + begin + end + rest)
  16. return subprocess.call(("mypy", "--config", cfg, *sys.argv[1:]))
  17. if __name__ == "__main__":
  18. raise SystemExit(main())