From 023fe1423890bf27f537e315246a95c0b6fa382e Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 28 Mar 2019 09:32:14 -0700 Subject: [PATCH] dependencies/base: Add type annotations to partial_dependency method This would have caught the bug that this series set out to fix. --- mesonbuild/dependencies/base.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index bbe025e79..1b8818d30 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -161,8 +161,9 @@ class Dependency: def get_configtool_variable(self, variable_name): raise DependencyException('{!r} is not a config-tool dependency'.format(self.name)) - def get_partial_dependency(self, *, compile_args=False, link_args=False, - links=False, includes=False, sources=False): + def get_partial_dependency(self, *, compile_args: bool = False, + link_args: bool = False, links: bool = False, + includes: bool = False, sources: bool = False): """Create a new dependency that contains part of the parent dependency. The following options can be inherited: @@ -200,8 +201,9 @@ class InternalDependency(Dependency): raise DependencyException('Method "get_configtool_variable()" is ' 'invalid for an internal dependency') - def get_partial_dependency(self, *, compile_args=False, link_args=False, - links=False, includes=False, sources=False): + def get_partial_dependency(self, *, compile_args: bool = False, + link_args: bool = False, links: bool = False, + includes: bool = False, sources: bool = False): compile_args = self.compile_args.copy() if compile_args else [] link_args = self.link_args.copy() if link_args else [] libraries = self.libraries.copy() if links else [] @@ -262,8 +264,9 @@ class ExternalDependency(Dependency): def get_compiler(self): return self.clib_compiler - def get_partial_dependency(self, *, compile_args=False, link_args=False, - links=False, includes=False, sources=False): + def get_partial_dependency(self, *, compile_args: bool = False, + link_args: bool = False, links: bool = False, + includes: bool = False, sources: bool = False): new = copy.copy(self) if not compile_args: new.compile_args = [] @@ -326,8 +329,9 @@ class NotFoundDependency(Dependency): self.name = 'not-found' self.is_found = False - def get_partial_dependency(self, *, compile_args=False, link_args=False, - links=False, includes=False, sources=False): + def get_partial_dependency(self, *, compile_args: bool = False, + link_args: bool = False, links: bool = False, + includes: bool = False, sources: bool = False): return copy.copy(self) @@ -2169,8 +2173,9 @@ class ExternalLibrary(ExternalDependency): return [] return super().get_link_args(**kwargs) - def get_partial_dependency(self, *, compile_args=False, link_args=False, - links=False, includes=False, sources=False): + def get_partial_dependency(self, *, compile_args: bool = False, + link_args: bool = False, links: bool = False, + includes: bool = False, sources: bool = False): # External library only has link_args, so ignore the rest of the # interface. new = copy.copy(self)