find_easiest_modules.py 718 B

12345678910111213141516171819202122232425262728
  1. from __future__ import annotations
  2. import collections
  3. import subprocess
  4. import sys
  5. def main() -> int:
  6. out = subprocess.run(
  7. (sys.executable, "-m", "tools.mypy_helpers.mypy_without_ignores", *sys.argv[1:]),
  8. capture_output=True,
  9. )
  10. counts: collections.Counter[str] = collections.Counter()
  11. for line in out.stdout.decode().splitlines():
  12. filename, _, _ = line.partition(":")
  13. if filename.endswith(".py"):
  14. counts[filename] += 1
  15. vals = [(count, fname) for fname, count in counts.most_common()]
  16. vals.sort(reverse=True)
  17. for count, fname in vals:
  18. print(f"{count}\t{fname}")
  19. return 0
  20. if __name__ == "__main__":
  21. raise SystemExit(main())