From 76bead7e15f402cb385c2a21116d8facd0daad75 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 8 Jul 2022 09:41:04 -0700 Subject: msetup: do some stupid casting to make mypy happy mypy is pretty dumb when it comes to unions of callables (pylance is also dumb in this regard), and can't figure out that our use of `mlog.debug | mlog.log` is perfectly safe. We also can't annotate them properly to cast them to a valid subset of arguments because you can't have splats in `typing.Callable`, so I've done enough to make it work. --- mesonbuild/msetup.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mesonbuild/msetup.py b/mesonbuild/msetup.py index 43594dd51..4b6d50882 100644 --- a/mesonbuild/msetup.py +++ b/mesonbuild/msetup.py @@ -206,10 +206,11 @@ class MesonApp: b = build.Build(env) intr = interpreter.Interpreter(b, user_defined_options=user_defined_options) - if env.is_cross_build(): - logger_fun = mlog.log - else: - logger_fun = mlog.debug + # Super hack because mlog.log and mlog.debug have different signatures, + # and there is currently no way to annotate them correctly, unionize them, or + # even to write `T.Callable[[*mlog.TV_Loggable], None]` + logger_fun = T.cast('T.Callable[[mlog.TV_Loggable, mlog.TV_Loggable], None]', + (mlog.log if env.is_cross_build() else mlog.debug)) build_machine = intr.builtin['build_machine'] host_machine = intr.builtin['host_machine'] target_machine = intr.builtin['target_machine'] -- cgit v1.2.3