Skip to content

Commit 7be9b42

Browse files
authored
Merge pull request #11136 from pradyunsg/fix-upgrade-prompt
2 parents b91dbde + 4cf6b17 commit 7be9b42

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

news/11136.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix an incorrect assertion in the logging logic, that prevented the upgrade prompt from being presented.

src/pip/_internal/utils/logging.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
Console,
1515
ConsoleOptions,
1616
ConsoleRenderable,
17+
RenderableType,
1718
RenderResult,
19+
RichCast,
1820
)
1921
from pip._vendor.rich.highlighter import NullHighlighter
2022
from pip._vendor.rich.logging import RichHandler
@@ -121,7 +123,7 @@ def format(self, record: logging.LogRecord) -> str:
121123

122124
@dataclass
123125
class IndentedRenderable:
124-
renderable: ConsoleRenderable
126+
renderable: RenderableType
125127
indent: int
126128

127129
def __rich_console__(
@@ -156,10 +158,10 @@ def emit(self, record: logging.LogRecord) -> None:
156158
if record.msg == "[present-rich] %s" and len(record.args) == 1:
157159
rich_renderable = record.args[0]
158160
assert isinstance(
159-
rich_renderable, ConsoleRenderable
161+
rich_renderable, (ConsoleRenderable, RichCast, str)
160162
), f"{rich_renderable} is not rich-console-renderable"
161163

162-
renderable: ConsoleRenderable = IndentedRenderable(
164+
renderable: RenderableType = IndentedRenderable(
163165
rich_renderable, indent=get_indentation()
164166
)
165167
else:

0 commit comments

Comments
 (0)