2020-03-08 12:09:46 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2020-05-04 10:49:03 +03:00
|
|
|
import os
|
2020-03-08 12:09:46 +03:00
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
2020-05-04 10:49:03 +03:00
|
|
|
base = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
files = [os.path.relpath(x, base) for x in sys.argv[1:] if not x.startswith('-')]
|
2020-03-08 12:09:46 +03:00
|
|
|
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] + ':'
|
2020-05-04 10:49:03 +03:00
|
|
|
rc = 0
|
2020-03-08 12:09:46 +03:00
|
|
|
for line in output.decode('utf-8').splitlines():
|
|
|
|
if line.startswith(q):
|
|
|
|
print(line)
|
2020-05-04 10:49:03 +03:00
|
|
|
rc = 1
|
|
|
|
raise SystemExit(rc)
|