interpreter: Add a few missing type annotations

Just enough to make interpreter/mesonmain happy
pull/9167/head
Dylan Baker 3 years ago
parent e4f4b76ddb
commit 88e5ff0575
  1. 9
      mesonbuild/interpreter/interpreter.py

@ -73,7 +73,9 @@ import importlib
if T.TYPE_CHECKING:
import argparse
from . import kwargs
from ..programs import OverrideProgram
# Input source types passed to Targets
SourceInputs = T.Union[mesonlib.File, build.GeneratedList, build.BuildTarget, build.BothLibraries,
@ -233,6 +235,7 @@ class Interpreter(InterpreterBase, HoldableObject):
user_defined_options: T.Optional['argparse.Namespace'] = None,
) -> None:
super().__init__(_build.environment.get_source_dir(), subdir, subproject)
self.active_projectname = ''
self.build = _build
self.environment = self.build.environment
self.coredata = self.environment.get_coredata()
@ -1337,7 +1340,7 @@ external dependencies (including libraries) must go to "dependencies".''')
if isinstance(name, str):
self.build.searched_programs.add(name)
def add_find_program_override(self, name, exe):
def add_find_program_override(self, name: str, exe: T.Union[build.Executable, ExternalProgram, 'OverrideProgram']) -> None:
if name in self.build.searched_programs:
raise InterpreterException(f'Tried to override finding of executable "{name}" which has already been found.')
if name in self.build.find_overrides:
@ -1430,7 +1433,7 @@ external dependencies (including libraries) must go to "dependencies".''')
@FeatureNewKwargs('find_program', '0.49.0', ['disabler'])
@disablerIfNotFound
@permittedKwargs({'required', 'native', 'version', 'dirs'})
def func_find_program(self, node, args, kwargs):
def func_find_program(self, node, args, kwargs) -> T.Union['build.Executable', ExternalProgram, 'OverrideProgram']:
if not args:
raise InterpreterException('No program name specified.')
@ -2643,7 +2646,7 @@ This will become a hard error in the future.''', location=self.current_node)
if self.subproject != buildtarget.subproject:
raise InterpreterException('Tried to extract objects from a different subproject.')
def is_subproject(self):
def is_subproject(self) -> bool:
return self.subproject != ''
@typed_pos_args('set_variable', str, object)

Loading…
Cancel
Save