diff options
Diffstat (limited to 'check_checkers.py')
-rwxr-xr-x | check_checkers.py | 28 |
1 files changed, 20 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: |