summary: fix dependencies

Dependencies are currently printed as

   [<mesonbuild.mlog.AnsiDecorator object at 0x7faa85aeac70>, ' ', <mesonbuild.mlog.AnsiDecorator object at 0x7faa85aeab50>]

This was introduced in commit adb1b2f3f6, due to
an incorrect type annotation on the AnsiText constructor.  Fix both the
annotation and the usage.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
pull/9295/head
Paolo Bonzini 3 years ago committed by Nirbheek Chauhan
parent 68edfe2e46
commit 4f05df83af
  1. 3
      mesonbuild/_typing.py
  2. 2
      mesonbuild/dependencies/base.py
  3. 4
      mesonbuild/mlog.py

@ -36,6 +36,9 @@ T = typing.TypeVar('T')
class StringProtocol(Protocol): class StringProtocol(Protocol):
def __str__(self) -> str: ... def __str__(self) -> str: ...
class SizedStringProtocol(Protocol, StringProtocol, typing.Sized):
pass
class ImmutableListProtocol(Protocol[T]): class ImmutableListProtocol(Protocol[T]):
"""A protocol used in cases where a list is returned, but should not be """A protocol used in cases where a list is returned, but should not be

@ -104,7 +104,7 @@ class Dependency(HoldableObject):
return mlog.red('NO') return mlog.red('NO')
if not self.version: if not self.version:
return mlog.green('YES') return mlog.green('YES')
return mlog.AnsiText([mlog.green('YES'), ' ', mlog.cyan(self.version)]) return mlog.AnsiText(mlog.green('YES'), ' ', mlog.cyan(self.version))
def get_compile_args(self) -> T.List[str]: def get_compile_args(self) -> T.List[str]:
if self.include_type == 'system': if self.include_type == 'system':

@ -22,7 +22,7 @@ from contextlib import contextmanager
from pathlib import Path from pathlib import Path
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from ._typing import StringProtocol from ._typing import StringProtocol, SizedStringProtocol
"""This is (mostly) a standalone module used to write logging """This is (mostly) a standalone module used to write logging
information about Meson runs. Some output goes to screen, information about Meson runs. Some output goes to screen,
@ -143,7 +143,7 @@ TV_Loggable = T.Union[str, AnsiDecorator, 'StringProtocol']
TV_LoggableList = T.List[TV_Loggable] TV_LoggableList = T.List[TV_Loggable]
class AnsiText: class AnsiText:
def __init__(self, *args: TV_LoggableList): def __init__(self, *args: 'SizedStringProtocol'):
self.args = args self.args = args
def __len__(self) -> int: def __len__(self) -> int:

Loading…
Cancel
Save