From d83a450260dbc2534a74fdc4284d1976e734990a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 Mar 2020 15:56:25 +0530 Subject: [PATCH] A command for test.py to generate the typing stubs and run mypy --- .gitignore | 1 + test.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 47b8844d5..ce0afb827 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.so *.pyc *.pyo +*_stub.pyi /tags /build/ /linux-package/ diff --git a/test.py b/test.py index aeb16309e..7ca67f2c7 100755 --- a/test.py +++ b/test.py @@ -65,6 +65,15 @@ def filter_tests_by_module(suite, *names): return filter_tests(suite, q) +def type_check(): + init_env() + from kitty.cli_stub import generate_stub + generate_stub() + from kitty.options_stub import generate_stub + generate_stub() + os.execlp('mypy', 'mypy') + + def run_tests(): import argparse parser = argparse.ArgumentParser() @@ -73,6 +82,8 @@ def run_tests(): help='The name of the test to run, for e.g. linebuf corresponds to test_linebuf. Can be specified multiple times') parser.add_argument('--verbosity', default=4, type=int, help='Test verbosity') args = parser.parse_args() + if args.name and args.name[0] in ('type-check', 'type_check', 'mypy'): + return type_check() tests = find_tests_in_dir(os.path.join(base, 'kitty_tests')) if args.name: tests = filter_tests_by_name(tests, *args.name)