From 0799ceac4c69cd4787ffed48b0afcfae93afe3f1 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Tue, 31 May 2022 16:30:30 +0530 Subject: [PATCH] Merge pull request #11136 from pradyunsg/fix-upgrade-prompt --- news/11136.bugfix.rst | 1 + src/pip/_internal/utils/logging.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 news/11136.bugfix.rst diff --git a/news/11136.bugfix.rst b/news/11136.bugfix.rst new file mode 100644 index 00000000000..817c33802fc --- /dev/null +++ b/news/11136.bugfix.rst @@ -0,0 +1 @@ +Fix an incorrect assertion in the logging logic, that prevented the upgrade prompt from being presented. diff --git a/src/pip/_internal/utils/logging.py b/src/pip/_internal/utils/logging.py index d6e991b89ec..c10e1f4ced6 100644 --- a/src/pip/_internal/utils/logging.py +++ b/src/pip/_internal/utils/logging.py @@ -14,7 +14,9 @@ Console, ConsoleOptions, ConsoleRenderable, + RenderableType, RenderResult, + RichCast, ) from pip._vendor.rich.highlighter import NullHighlighter from pip._vendor.rich.logging import RichHandler @@ -121,7 +123,7 @@ def format(self, record: logging.LogRecord) -> str: @dataclass class IndentedRenderable: - renderable: ConsoleRenderable + renderable: RenderableType indent: int def __rich_console__( @@ -156,10 +158,10 @@ def emit(self, record: logging.LogRecord) -> None: if record.msg == "[present-rich] %s" and len(record.args) == 1: rich_renderable = record.args[0] assert isinstance( - rich_renderable, ConsoleRenderable + rich_renderable, (ConsoleRenderable, RichCast, str) ), f"{rich_renderable} is not rich-console-renderable" - renderable: ConsoleRenderable = IndentedRenderable( + renderable: RenderableType = IndentedRenderable( rich_renderable, indent=get_indentation() ) else: