kitty/mypy-editor-integration

20 lines
581 B
Python
Executable File

#!/usr/bin/env python
import os
import subprocess
import sys
base = os.path.dirname(os.path.abspath(__file__))
files = [os.path.relpath(x, base) for x in sys.argv[1:] if not x.startswith('-')]
if not files:
raise SystemExit(subprocess.Popen(['mypy'] + sys.argv[1:]).wait())
output = subprocess.run('dmypy run -- --follow-imports=error --show-column-numbers --no-color-output'.split(), stdout=subprocess.PIPE).stdout
q = files[0] + ':'
rc = 0
for line in output.decode('utf-8').splitlines():
if line.startswith(q):
print(line)
rc = 1
raise SystemExit(rc)