Skip to content

Commit a89354a

Browse files
committed
harden typecheck script
1 parent 9785d88 commit a89354a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ci-image/scripts/typecheck.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def typecheck_files(filenames):
3232
my_report[filename].errors += 1
3333
elif severity == "warning":
3434
my_report[filename].warnings += 1
35-
start = diagnostic["range"]["start"]
35+
start = diagnostic.get("range", {"start": {"line": 1, "character": 1}})["start"]
3636
my_report[filename].diagnostics.append((start["line"], start["character"], severity, diagnostic["message"]))
3737

3838
for report in my_report.values():
@@ -48,10 +48,10 @@ def typecheck_diff(rev1, rev2):
4848
print()
4949
filenames = subprocess.check_output(["git", "diff", "--name-only", f"{rev1}...{rev2}"], text=True).splitlines()
5050
filenames = filter_py(filenames)
51-
subprocess.check_call(["git", "checkout", rev1], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
52-
report1 = typecheck_files(filenames)
5351
subprocess.check_call(["git", "checkout", rev2], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
5452
report2 = typecheck_files(filenames)
53+
subprocess.check_call(["git", "checkout", rev1], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
54+
report1 = typecheck_files(report2)
5555

5656
status = 0
5757

0 commit comments

Comments
 (0)