From 4ca883ac9fcec004b8c4280b788a0f7bdd26e00c Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 9 Oct 2023 11:20:48 -0700 Subject: [PATCH] interpreter: extend annotations around build_both_libraries This allows for even more accurate type information --- mesonbuild/interpreter/interpreter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index c7dc92d5d70f..5ff5c0b5001d 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -3186,7 +3186,7 @@ def add_target(self, name: str, tobj: build.Target) -> None: self.coredata.target_guids[idname] = str(uuid.uuid4()).upper() @FeatureNew('both_libraries', '0.46.0') - def build_both_libraries(self, node, args, kwargs): + def build_both_libraries(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargsType], kwargs: kwtypes.Library) -> build.BothLibraries: shared_lib = self.build_target(node, args, kwargs, build.SharedLibrary) static_lib = self.build_target(node, args, kwargs, build.StaticLibrary) @@ -3219,12 +3219,13 @@ def build_both_libraries(self, node, args, kwargs): return build.BothLibraries(shared_lib, static_lib) - def build_library(self, node, args, kwargs): + def build_library(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargsType], kwargs: kwtypes.Library): default_library = self.coredata.get_option(OptionKey('default_library', subproject=self.subproject)) + assert isinstance(default_library, str), 'for mypy' if default_library == 'shared': - return self.build_target(node, args, kwargs, build.SharedLibrary) + return self.build_target(node, args, T.cast('kwtypes.StaticLibrary', kwargs), build.SharedLibrary) elif default_library == 'static': - return self.build_target(node, args, kwargs, build.StaticLibrary) + return self.build_target(node, args, T.cast('kwtypes.SharedLibrary', kwargs), build.StaticLibrary) elif default_library == 'both': return self.build_both_libraries(node, args, kwargs) else: