summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck_checkers.py28
-rw-r--r--issues.toml7
-rw-r--r--requirements.txt6
3 files changed, 33 insertions, 8 deletions
diff --git a/check_checkers.py b/check_checkers.py
index 8ce03fa..65d1eec 100755
--- a/check_checkers.py
+++ b/check_checkers.py
@@ -13,6 +13,7 @@ import mypy.api
from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.lexers import PythonLexer
+import tomli
Error = Tuple[str, int, str]
@@ -156,10 +157,13 @@ def run(
default_typeshed: str,
out: TextIO,
cache: Dict[str, Puzzle],
+ issues: Dict[str, Dict[str, str]],
):
python_lexer = PythonLexer()
html_formatter = HtmlFormatter(noclasses=True, linenos='table')
- out.write("<meta charset=utf-8><title>Comparison of static type checkers for Python</title>")
+ out.write(
+ "<meta charset=utf-8><title>Comparison of static type checkers for Python</title>"
+ )
out.write(
'''<p>This page compares three static type checkers for Python.
The <span class=unexpected>red</span> background indicates that the checker
@@ -201,13 +205,8 @@ def run(
for checker in checkers:
errors = checker_results[checker.__class__.__name__]
- out.write(
- '<td class="{}">'.format(
- 'ok'
- if (errors and error_ok) or (not errors and no_error_ok)
- else 'unexpected'
- )
- )
+ expected = (errors and error_ok) or (not errors and no_error_ok)
+ out.write('<td class="{}">'.format('ok' if expected else 'unexpected'))
if errors:
out.write('<ul>')
for filename, line, message in errors:
@@ -217,6 +216,15 @@ def run(
out.write('</ul>')
else:
out.write('<center>no errors found')
+ if not expected:
+ checker_issues = issues.get(checker.__class__.__name__.lower(), {})
+ issue = checker_issues.get(
+ os.path.splitext(os.path.basename(puzzle))[0]
+ )
+ if issue:
+ out.write('<br>(')
+ out.write(issue)
+ out.write(')')
out.write('</table>')
@@ -230,6 +238,9 @@ if __name__ == '__main__':
except FileNotFoundError:
cache = {}
+ with open('issues.toml', 'rb') as f:
+ issues = tomli.load(f)
+
with open('dist/checkers.html', 'w') as f:
run(
[Mypy(), Pytype(), Pyright()],
@@ -237,6 +248,7 @@ if __name__ == '__main__':
typeshed,
f,
cache,
+ issues,
)
with open('cache.json', 'w') as f:
diff --git a/issues.toml b/issues.toml
new file mode 100644
index 0000000..a840797
--- /dev/null
+++ b/issues.toml
@@ -0,0 +1,7 @@
+[mypy]
+infer_return_basic = "mypy intentionally treats unannotated functions as returning Any"
+tricky_recursive = '<a href="https://github.com/python/mypy/issues/731">issue 731</a>'
+tricky_typevar_constrained = '<a href="https://github.com/python/mypy/issues/11880">issue 11880</a>'
+
+[pytype]
+tricky_enum = '<a href="https://github.com/google/pytype/issues/790">issue 790</a>'
diff --git a/requirements.txt b/requirements.txt
index bb5abe7..4d9646f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -6,3 +6,9 @@ pyserde==0.7.0
serdelicacy==0.18.1
typedload==2.15
typical==2.8.0
+
+pytype==2022.1.13
+mypy==0.931
+
+pygments==2.11.1
+tomli==1.2.3