From 3e97a95f9dc974771823d5f4f3cedd66b4b05f5f Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 8 Jul 2022 09:32:06 -0700 Subject: dependencies/dev: refactor some code to make mypy happy There should be a way to make mypy happy without casting, but I can't figure it out, since the mlog.error and mlog.debug actually have different signatures. --- mesonbuild/dependencies/dev.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index cc02842..fd43a27 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -534,8 +534,11 @@ class JNISystemDependency(SystemDependency): modules: T.List[str] = mesonlib.listify(kwargs.get('modules', [])) for module in modules: if module not in {'jvm', 'awt'}: - log = mlog.error if self.required else mlog.debug - log(f'Unknown JNI module ({module})') + msg = f'Unknown JNI module ({module})' + if self.required: + mlog.error(msg) + else: + mlog.debug(msg) self.is_found = False return @@ -553,8 +556,11 @@ class JNISystemDependency(SystemDependency): res = subprocess.run(['/usr/libexec/java_home', '--failfast', '--arch', m.cpu_family], stdout=subprocess.PIPE) if res.returncode != 0: - log = mlog.error if self.required else mlog.debug - log('JAVA_HOME could not be discovered on the system. Please set it explicitly.') + msg = 'JAVA_HOME could not be discovered on the system. Please set it explicitly.' + if self.required: + mlog.error(msg) + else: + mlog.debug(msg) self.is_found = False return self.java_home = pathlib.Path(res.stdout.decode().strip()) -- cgit v1.1