diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2022-07-08 09:41:04 -0700 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2023-01-03 14:49:02 -0500 |
| commit | 76bead7e15f402cb385c2a21116d8facd0daad75 (patch) | |
| tree | f6c194da6ab5497bcf93788454900a60d52aeae0 | |
| parent | 3e97a95f9dc974771823d5f4f3cedd66b4b05f5f (diff) | |
| download | meson-76bead7e15f402cb385c2a21116d8facd0daad75.tar.gz | |
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.
| -rw-r--r-- | mesonbuild/msetup.py | 9 |
1 files 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'] |
