aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-09-07 13:30:47 +0200
committerXavier Claessens <xclaesse@gmail.com>2021-09-07 14:18:58 -0400
commit516c871beca90caa2a1433579e6450f5a6c65817 (patch)
tree53ff3301168affe4d531bca9a48096dc966bc33d
parentaf8b55d49b64e72dbefbd40d613b93f56d17b855 (diff)
downloadmeson-516c871beca90caa2a1433579e6450f5a6c65817.zip
meson-516c871beca90caa2a1433579e6450f5a6c65817.tar.gz
meson-516c871beca90caa2a1433579e6450f5a6c65817.tar.bz2
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 adb1b2f3f6ad54b346348ec6e5b8d96f2f7ba0a6, 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>
-rw-r--r--mesonbuild/_typing.py3
-rw-r--r--mesonbuild/dependencies/base.py2
-rw-r--r--mesonbuild/mlog.py4
3 files changed, 6 insertions, 3 deletions
diff --git a/mesonbuild/_typing.py b/mesonbuild/_typing.py
index a01be33..31a6e18 100644
--- a/mesonbuild/_typing.py
+++ b/mesonbuild/_typing.py
@@ -36,6 +36,9 @@ T = typing.TypeVar('T')
class StringProtocol(Protocol):
def __str__(self) -> str: ...
+class SizedStringProtocol(Protocol, StringProtocol, typing.Sized):
+ pass
+
class ImmutableListProtocol(Protocol[T]):
"""A protocol used in cases where a list is returned, but should not be
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 45aec75..870d164 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -103,7 +103,7 @@ class Dependency(HoldableObject):
return mlog.red('NO')
if not self.version:
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]:
if self.include_type == 'system':
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index 314e1b7..06d8a0b 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -22,7 +22,7 @@ from contextlib import contextmanager
from pathlib import Path
if T.TYPE_CHECKING:
- from ._typing import StringProtocol
+ from ._typing import StringProtocol, SizedStringProtocol
"""This is (mostly) a standalone module used to write logging
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]
class AnsiText:
- def __init__(self, *args: TV_LoggableList):
+ def __init__(self, *args: 'SizedStringProtocol'):
self.args = args
def __len__(self) -> int: