summaryrefslogtreecommitdiff
path: root/check_checkers.py
diff options
context:
space:
mode:
Diffstat (limited to 'check_checkers.py')
-rwxr-xr-xcheck_checkers.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/check_checkers.py b/check_checkers.py
index e46bb12..4b78509 100755
--- a/check_checkers.py
+++ b/check_checkers.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
+import hashlib
import html
import json
import os
@@ -153,7 +154,7 @@ class PyrightStrict(Pyright):
class Puzzle(TypedDict):
checker_results: Dict[str, List[Error]]
- last_modified: int
+ puzzle_hash: str
def run_checkers(checkers: List[Checker], puzzle: str, typeshed_path: str):
@@ -225,13 +226,16 @@ def run(
for puzzle in puzzles:
print(puzzle)
- last_modified = int(os.stat(puzzle).st_mtime)
- if puzzle in cache and last_modified == cache[puzzle]['last_modified']:
+ with open(puzzle, 'rb') as f:
+ code = f.read()
+
+ puzzle_hash = hashlib.sha256(code).hexdigest()
+ if puzzle in cache and puzzle_hash == cache[puzzle]['puzzle_hash']:
checker_results = cache[puzzle]['checker_results']
else:
checker_results = run_checkers(checkers, puzzle, default_typeshed)
cache[puzzle] = {
- 'last_modified': last_modified,
+ 'puzzle_hash': puzzle_hash,
'checker_results': checker_results,
}
@@ -241,8 +245,7 @@ def run(
.replace('_', '-')
)
out.write('<tr><td id="{0}"><a href="#{0}">{0}</a>'.format(anchor))
- with open(puzzle) as f:
- code = f.read()
+ code = code.decode('utf-8')
out.write(highlight(code, python_lexer, html_formatter))
error_ok = '# error' in code or '# maybe error' in code
no_error_ok = '# error' not in code