A command for test.py to generate the typing stubs and run mypy

This commit is contained in:
Kovid Goyal 2020-03-05 15:56:25 +05:30
parent 61acc0784e
commit d83a450260
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.so *.so
*.pyc *.pyc
*.pyo *.pyo
*_stub.pyi
/tags /tags
/build/ /build/
/linux-package/ /linux-package/

11
test.py
View File

@ -65,6 +65,15 @@ def filter_tests_by_module(suite, *names):
return filter_tests(suite, q) 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(): def run_tests():
import argparse import argparse
parser = argparse.ArgumentParser() 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') 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') parser.add_argument('--verbosity', default=4, type=int, help='Test verbosity')
args = parser.parse_args() 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')) tests = find_tests_in_dir(os.path.join(base, 'kitty_tests'))
if args.name: if args.name:
tests = filter_tests_by_name(tests, *args.name) tests = filter_tests_by_name(tests, *args.name)