44import json
55import errno
66
7- from typing import List , Iterable
7+ from typing import Any , List , Iterable , Never , Sequence
88
99CONF_YML : str = "conf.yml"
1010
1111
1212class Config (object ):
13+ stages : list [str ] | None
14+
1315 def __init__ (self , args ):
1416 self .verbose = args .verbose
1517 self .projects = args .projects # projects filter
@@ -18,8 +20,8 @@ def __init__(self, args):
1820 self .project_dirs = find_project_dirs (self )
1921 self .project_conf = {cf : get_yaml (cf ) for cf in get_conf_files (self )}
2022
21- def try_get_conf_for (self , conf_file , * keys : List [ str ] ):
22- def lookup (yaml , keys : List [str ]):
23+ def try_get_conf_for (self , conf_file , * keys : str ):
24+ def lookup (yaml , keys : Sequence [str ]):
2325 if not keys :
2426 return None
2527 head , * tail = keys
@@ -44,7 +46,7 @@ class Colors(object):
4446 NO_COLOR = '\033 [0m'
4547
4648
47- def die (emsg : str , status : int = errno .EINVAL ):
49+ def die (emsg : str , status : int = errno .EINVAL ) -> Never :
4850 (red , nc ) = (Colors .FAIL , Colors .NO_COLOR )
4951 print (f"{ red } error:{ nc } { emsg } " , file = sys .stderr )
5052 exit (status )
@@ -97,15 +99,15 @@ def find_project_dirs(conf: Config) -> List[str]:
9799 return [os .path .join (script_dir , s ) for s in subdirs ]
98100
99101
100- def get_yaml (file : str ) -> dict :
102+ def get_yaml (file : str ) -> dict [ str , Any ] :
101103 with open (file , 'r' ) as stream :
102104 try :
103105 return yaml .safe_load (stream )
104106 except yaml .YAMLError as exc :
105107 die (str (exc ))
106108
107109
108- def check_compile_commands (compile_commands_path : str ) -> ( bool , str ) :
110+ def check_compile_commands (compile_commands_path : str ) -> tuple [ bool , str ] :
109111 """
110112 Return True iff compile_commands_path points to a valid
111113 compile_commands.json and all referenced source files exist.
0 commit comments