55# file COPYING or http://www.opensource.org/licenses/mit-license.php.
66
77"""
8- Check for specified mypy warnings in python files.
8+ Check for type errors in python files using ty .
99"""
1010
11- import os
12- from pathlib import Path
11+ import shutil
1312import subprocess
1413
1514from importlib .metadata import metadata , PackageNotFoundError
1615
17- # Customize mypy cache dir via environment variable
18- cache_dir = Path (__file__ ).parent .parent / ".mypy_cache"
19- os .environ ["MYPY_CACHE_DIR" ] = str (cache_dir )
20-
21- DEPS = ['lief' , 'mypy' , 'pyzmq' ]
22-
23- # Only .py files in test/functional and contrib/devtools have type annotations
24- # enforced.
25- MYPY_FILES_ARGS = ['git' , 'ls-files' , 'test/functional/*.py' , 'contrib/devtools/*.py' ]
16+ DEPS = ['lief' , 'pyzmq' ]
2617
2718
2819def check_dependencies ():
@@ -33,15 +24,16 @@ def check_dependencies():
3324 print (f"Skipping Python linting since { dep } is not installed." )
3425 exit (0 )
3526
27+ if not shutil .which ('ty' ):
28+ print ("Skipping Python linting since ty is not installed." )
29+ exit (0 )
30+
3631
3732def main ():
3833 check_dependencies ()
3934
40- mypy_files = subprocess .check_output (MYPY_FILES_ARGS , text = True ).splitlines ()
41- mypy_args = ['mypy' , '--show-error-codes' ] + mypy_files
42-
4335 try :
44- subprocess .check_call (mypy_args )
36+ subprocess .check_call ([ 'ty' , 'check' ] )
4537 except subprocess .CalledProcessError :
4638 exit (1 )
4739
0 commit comments