From edbfd5cd4f2a6d38a1da630c009cc40472fdd423 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Thu, 24 Feb 2022 08:24:51 +0100 Subject: checkers: add mypy with --strict --- check_checkers.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'check_checkers.py') diff --git a/check_checkers.py b/check_checkers.py index 90ccc43..e8b1b2f 100755 --- a/check_checkers.py +++ b/check_checkers.py @@ -21,7 +21,9 @@ Error = Tuple[str, int, str] class Checker: + name: str url: str + extra_flags: Tuple[str, ...] = () def run(self, path: str, typeshed_path: str) -> List[Error]: """ @@ -35,6 +37,7 @@ class Checker: class Mypy(Checker): + name = 'Mypy' url = 'https://github.com/python/mypy' # mypy cannot output JSON (https://github.com/python/mypy/issues/10816) @@ -53,6 +56,7 @@ class Mypy(Checker): # fmt: off '--cache-dir', cachedir, '--custom-typeshed-dir', typeshed_path, + *cls.extra_flags, # fmt: on '--', path, @@ -69,7 +73,12 @@ class Mypy(Checker): return mypy.api.run(['--version'])[0].split()[1].strip() +class MypyStrict(Mypy): + extra_flags = ('--strict',) + + class Pytype(Checker): + name = 'Pytype' url = 'https://github.com/google/pytype' # pytype supports CSV output only for pytype-single which however doesn't support multiple modules @@ -101,6 +110,7 @@ class Pytype(Checker): class Pyright(Checker): + name = 'Pyright' url = 'https://github.com/microsoft/pyright' @staticmethod @@ -178,8 +188,11 @@ def run( for checker in checkers: out.write('') out.write(''.format(html.escape(checker.url))) - out.write(checker.__class__.__name__) + out.write(checker.name) out.write('') + if checker.extra_flags: + out.write(' with ') + out.write(', '.join(f'{html.escape(flag)}' for flag in checker.extra_flags)) out.write('
({})'.format(html.escape(checker.version()))) out.write('') @@ -217,7 +230,12 @@ def run( else: out.write('
no errors found') if not expected: - checker_issues = issues.get(checker.__class__.__name__.lower(), {}) + checker_issues = issues.get( + checker.__class__.__name__.lower(), + issues.get( + checker.__class__.__name__.lower().replace('strict', ''), {} + ), + ) issue = checker_issues.get( os.path.splitext(os.path.basename(puzzle))[0].split( '_', maxsplit=1 @@ -245,7 +263,7 @@ if __name__ == '__main__': with open('dist/checkers.html', 'w') as f: run( - [Mypy(), Pytype(), Pyright()], + [Mypy(), MypyStrict(), Pytype(), Pyright()], ['puzzles/' + f for f in sorted(os.listdir('puzzles'))], typeshed, f, -- cgit v1.2.3