interpreter: add type annotations to func_declare_dependency

pull/11780/merge
Dylan Baker 2 years ago
parent a151b10988
commit 7abd4d39c1
  1. 7
      mesonbuild/interpreter/interpreter.py
  2. 18
      mesonbuild/interpreter/kwargs.py

@ -691,7 +691,8 @@ class Interpreter(InterpreterBase, HoldableObject):
KwargInfo('version', (str, NoneType)),
KwargInfo('objects', ContainerTypeInfo(list, build.ExtractedObjects), listify=True, default=[], since='1.1.0'),
)
def func_declare_dependency(self, node, args, kwargs):
def func_declare_dependency(self, node: mparser.BaseNode, args: T.List[TYPE_var],
kwargs: kwtypes.FuncDeclareDependency) -> dependencies.Dependency:
deps = kwargs['dependencies']
incs = self.extract_incdirs(kwargs)
libs = kwargs['link_with']
@ -2738,7 +2739,7 @@ class Interpreter(InterpreterBase, HoldableObject):
install_tag=install_tag, data_type='configure'))
return mesonlib.File.from_built_file(self.subdir, output)
def extract_incdirs(self, kwargs, key: str = 'include_directories'):
def extract_incdirs(self, kwargs, key: str = 'include_directories') -> T.List[build.IncludeDirs]:
prospectives = extract_as_list(kwargs, key)
if key == 'include_directories':
for i in prospectives:
@ -2747,7 +2748,7 @@ class Interpreter(InterpreterBase, HoldableObject):
f'Use include_directories({i!r}) instead', location=self.current_node)
break
result = []
result: T.List[build.IncludeDirs] = []
for p in prospectives:
if isinstance(p, build.IncludeDirs):
result.append(p)

@ -12,6 +12,7 @@ from typing_extensions import TypedDict, Literal, Protocol
from .. import build
from .. import coredata
from ..compilers import Compiler
from ..dependencies.base import Dependency
from ..mesonlib import EnvironmentVariables, MachineChoice, File, FileMode, FileOrString, OptionKey
from ..modules.cmake import CMakeSubprojectOptions
from ..programs import ExternalProgram
@ -360,3 +361,20 @@ class Jar(_BaseBuildTarget):
main_class: str
java_resources: T.Optional[build.StructuredSources]
class FuncDeclareDependency(TypedDict):
compile_args: T.List[str]
d_import_dirs: T.List[T.Union[build.IncludeDirs, str]]
d_module_versions: T.List[T.Union[str, int]]
dependencies: T.List[Dependency]
extra_files: T.List[FileOrString]
include_directories: T.List[T.Union[build.IncludeDirs, str]]
link_args: T.List[str]
link_whole: T.List[T.Union[build.StaticLibrary, build.CustomTarget, build.CustomTargetIndex]]
link_with: T.List[build.LibTypes]
objects: T.List[build.ExtractedObjects]
sources: T.List[T.Union[FileOrString, build.GeneratedTypes]]
variables: T.Dict[str, str]
version: T.Optional[str]

Loading…
Cancel
Save