Skip to content

Commit

Permalink
interpreter: extend annotations around build_both_libraries
Browse files Browse the repository at this point in the history
This allows for even more accurate type information
  • Loading branch information
dcbaker committed Oct 9, 2023
1 parent 304c55d commit 4ca883a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4ca883a

Please sign in to comment.