From b6705e0373cac3111d1316070d71f26db09b3f63 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Wed, 23 Feb 2022 17:16:19 +0100 Subject: link github issues --- check_checkers.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'check_checkers.py') 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("Comparison of static type checkers for Python") + out.write( + "Comparison of static type checkers for Python" + ) out.write( '''

This page compares three static type checkers for Python. The red background indicates that the checker @@ -201,13 +205,8 @@ def run( for checker in checkers: errors = checker_results[checker.__class__.__name__] - out.write( - ''.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(''.format('ok' if expected else 'unexpected')) if errors: out.write('

') else: out.write('
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('
(') + out.write(issue) + out.write(')') out.write('') @@ -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: -- cgit v1.2.3