@@ -78,7 +78,8 @@ def _get_env_var(for_machine: MachineChoice, is_cross: bool, var_name: str) -> T
7878 return value
7979
8080
81- def detect_gcovr (gcovr_exe : str = 'gcovr' , min_version : str = '3.3' , log : bool = False ):
81+ def detect_gcovr (gcovr_exe : str = 'gcovr' , min_version : str = '3.3' , log : bool = False ) \
82+ -> T .Union [T .Tuple [None , None ], T .Tuple [str , str ]]:
8283 try :
8384 p , found = Popen_safe ([gcovr_exe , '--version' ])[0 :2 ]
8485 except (FileNotFoundError , PermissionError ):
@@ -91,7 +92,8 @@ def detect_gcovr(gcovr_exe: str = 'gcovr', min_version: str = '3.3', log: bool =
9192 return gcovr_exe , found
9293 return None , None
9394
94- def detect_lcov (lcov_exe : str = 'lcov' , log : bool = False ):
95+ def detect_lcov (lcov_exe : str = 'lcov' , log : bool = False ) \
96+ -> T .Union [T .Tuple [None , None ], T .Tuple [str , str ]]:
9597 try :
9698 p , found = Popen_safe ([lcov_exe , '--version' ])[0 :2 ]
9799 except (FileNotFoundError , PermissionError ):
@@ -104,7 +106,7 @@ def detect_lcov(lcov_exe: str = 'lcov', log: bool = False):
104106 return lcov_exe , found
105107 return None , None
106108
107- def detect_llvm_cov (suffix : T .Optional [str ] = None ):
109+ def detect_llvm_cov (suffix : T .Optional [str ] = None ) -> T . Optional [ str ] :
108110 # If there's a known suffix or forced lack of suffix, use that
109111 if suffix is not None :
110112 if suffix == '' :
@@ -121,7 +123,7 @@ def detect_llvm_cov(suffix: T.Optional[str] = None):
121123 return tool
122124 return None
123125
124- def compute_llvm_suffix (coredata : coredata .CoreData ):
126+ def compute_llvm_suffix (coredata : coredata .CoreData ) -> T . Optional [ str ] :
125127 # Check to see if the user is trying to do coverage for either a C or C++ project
126128 compilers = coredata .compilers [MachineChoice .BUILD ]
127129 cpp_compiler_is_clang = 'cpp' in compilers and compilers ['cpp' ].id == 'clang'
@@ -139,7 +141,8 @@ def compute_llvm_suffix(coredata: coredata.CoreData):
139141 # Neither compiler is a Clang, or no compilers are for C or C++
140142 return None
141143
142- def detect_lcov_genhtml (lcov_exe : str = 'lcov' , genhtml_exe : str = 'genhtml' ):
144+ def detect_lcov_genhtml (lcov_exe : str = 'lcov' , genhtml_exe : str = 'genhtml' ) \
145+ -> T .Tuple [str , T .Optional [str ], str ]:
143146 lcov_exe , lcov_version = detect_lcov (lcov_exe )
144147 if shutil .which (genhtml_exe ) is None :
145148 genhtml_exe = None
@@ -162,7 +165,7 @@ def detect_ninja(version: str = '1.8.2', log: bool = False) -> T.Optional[T.List
162165 r = detect_ninja_command_and_version (version , log )
163166 return r [0 ] if r else None
164167
165- def detect_ninja_command_and_version (version : str = '1.8.2' , log : bool = False ) -> T .Tuple [T .List [str ], str ]:
168+ def detect_ninja_command_and_version (version : str = '1.8.2' , log : bool = False ) -> T .Optional [ T . Tuple [T .List [str ], str ] ]:
166169 env_ninja = os .environ .get ('NINJA' , None )
167170 for n in [env_ninja ] if env_ninja else ['ninja' , 'ninja-build' , 'samu' ]:
168171 prog = ExternalProgram (n , silent = True )
@@ -188,6 +191,7 @@ def detect_ninja_command_and_version(version: str = '1.8.2', log: bool = False)
188191 mlog .log ('Found {}-{} at {}' .format (name , found ,
189192 ' ' .join ([quote_arg (x ) for x in prog .command ])))
190193 return (prog .command , found )
194+ return None
191195
192196def get_llvm_tool_names (tool : str ) -> T .List [str ]:
193197 # Ordered list of possible suffixes of LLVM executables to try. Start with
@@ -532,7 +536,7 @@ def detect_machine_info(compilers: T.Optional[CompilersDict] = None) -> MachineI
532536
533537# TODO make this compare two `MachineInfo`s purely. How important is the
534538# `detect_cpu_family({})` distinction? It is the one impediment to that.
535- def machine_info_can_run (machine_info : MachineInfo ):
539+ def machine_info_can_run (machine_info : MachineInfo ) -> bool :
536540 """Whether we can run binaries for this machine on the current machine.
537541
538542 Can almost always run 32-bit binaries on 64-bit natively if the host
@@ -906,7 +910,7 @@ def is_object(self, fname: 'mesonlib.FileOrString') -> bool:
906910 return is_object (fname )
907911
908912 @lru_cache (maxsize = None )
909- def is_library (self , fname : mesonlib .FileOrString ):
913+ def is_library (self , fname : mesonlib .FileOrString ) -> bool :
910914 return is_library (fname )
911915
912916 def lookup_binary_entry (self , for_machine : MachineChoice , name : str ) -> T .Optional [T .List [str ]]:
@@ -997,9 +1001,10 @@ def get_compiler_system_include_dirs(self, for_machine: MachineChoice) -> T.List
9971001 return []
9981002 return comp .get_default_include_dirs ()
9991003
1000- def need_exe_wrapper (self , for_machine : MachineChoice = MachineChoice .HOST ):
1004+ def need_exe_wrapper (self , for_machine : MachineChoice = MachineChoice .HOST ) -> bool :
10011005 value = self .properties [for_machine ].get ('needs_exe_wrapper' , None )
10021006 if value is not None :
1007+ assert isinstance (value , bool ), 'for mypy'
10031008 return value
10041009 if not self .is_cross_build ():
10051010 return False
0 commit comments