Skip to content

Commit 58f5d87

Browse files
committed
Upgrade rich to 14.1.0
1 parent 18e50fd commit 58f5d87

19 files changed

+160
-164
lines changed

news/rich.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade rich to 14.1.0

src/pip/_vendor/rich/__main__.py

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ def iter_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
207207

208208

209209
if __name__ == "__main__": # pragma: no cover
210+
from pip._vendor.rich.panel import Panel
211+
210212
console = Console(
211213
file=io.StringIO(),
212214
force_terminal=True,
@@ -227,47 +229,17 @@ def iter_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
227229
c = Console(record=True)
228230
c.print(test_card)
229231

230-
print(f"rendered in {pre_cache_taken}ms (cold cache)")
231-
print(f"rendered in {taken}ms (warm cache)")
232-
233-
from pip._vendor.rich.panel import Panel
234-
235232
console = Console()
236-
237-
sponsor_message = Table.grid(padding=1)
238-
sponsor_message.add_column(style="green", justify="right")
239-
sponsor_message.add_column(no_wrap=True)
240-
241-
sponsor_message.add_row(
242-
"Textualize",
243-
"[u blue link=https://github.com/textualize]https://github.com/textualize",
244-
)
245-
sponsor_message.add_row(
246-
"Twitter",
247-
"[u blue link=https://twitter.com/willmcgugan]https://twitter.com/willmcgugan",
248-
)
249-
250-
intro_message = Text.from_markup(
251-
"""\
252-
We hope you enjoy using Rich!
253-
254-
Rich is maintained with [red]:heart:[/] by [link=https://www.textualize.io]Textualize.io[/]
255-
256-
- Will McGugan"""
257-
)
258-
259-
message = Table.grid(padding=2)
260-
message.add_column()
261-
message.add_column(no_wrap=True)
262-
message.add_row(intro_message, sponsor_message)
263-
233+
console.print(f"[dim]rendered in [not dim]{pre_cache_taken}ms[/] (cold cache)")
234+
console.print(f"[dim]rendered in [not dim]{taken}ms[/] (warm cache)")
235+
console.print()
264236
console.print(
265237
Panel.fit(
266-
message,
267-
box=box.ROUNDED,
268-
padding=(1, 2),
269-
title="[b red]Thanks for trying out Rich!",
270-
border_style="bright_blue",
271-
),
272-
justify="center",
238+
"[b magenta]Hope you enjoy using Rich![/]\n\n"
239+
"Please consider sponsoring me if you get value from my work.\n\n"
240+
"Even the price of a ☕ can brighten my day!\n\n"
241+
"https://github.com/sponsors/willmcgugan",
242+
border_style="red",
243+
title="Help ensure Rich is maintained",
244+
)
273245
)

src/pip/_vendor/rich/_inspect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def safe_getattr(attr_name: str) -> Tuple[Any, Any]:
214214
def _get_formatted_doc(self, object_: Any) -> Optional[str]:
215215
"""
216216
Extract the docstring of an object, process it and returns it.
217-
The processing consists in cleaning up the doctring's indentation,
217+
The processing consists in cleaning up the docstring's indentation,
218218
taking only its 1st paragraph if `self.help` is not True,
219219
and escape its control codes.
220220

src/pip/_vendor/rich/_ratio.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import sys
21
from fractions import Fraction
32
from math import ceil
4-
from typing import cast, List, Optional, Sequence
5-
6-
if sys.version_info >= (3, 8):
7-
from typing import Protocol
8-
else:
9-
from pip._vendor.typing_extensions import Protocol # pragma: no cover
3+
from typing import cast, List, Optional, Sequence, Protocol
104

115

126
class Edge(Protocol):

src/pip/_vendor/rich/align.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
import sys
21
from itertools import chain
3-
from typing import TYPE_CHECKING, Iterable, Optional
4-
5-
if sys.version_info >= (3, 8):
6-
from typing import Literal
7-
else:
8-
from pip._vendor.typing_extensions import Literal # pragma: no cover
2+
from typing import TYPE_CHECKING, Iterable, Optional, Literal
93

104
from .constrain import Constrain
115
from .jupyter import JupyterMixin

src/pip/_vendor/rich/box.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import sys
2-
from typing import TYPE_CHECKING, Iterable, List
3-
4-
if sys.version_info >= (3, 8):
5-
from typing import Literal
6-
else:
7-
from pip._vendor.typing_extensions import Literal # pragma: no cover
1+
from typing import TYPE_CHECKING, Iterable, List, Literal
82

93

104
from ._loop import loop_last

src/pip/_vendor/rich/console.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,21 @@
2222
Dict,
2323
Iterable,
2424
List,
25+
Literal,
2526
Mapping,
2627
NamedTuple,
2728
Optional,
29+
Protocol,
2830
TextIO,
2931
Tuple,
3032
Type,
3133
Union,
3234
cast,
35+
runtime_checkable,
3336
)
3437

3538
from pip._vendor.rich._null_file import NULL_FILE
3639

37-
if sys.version_info >= (3, 8):
38-
from typing import Literal, Protocol, runtime_checkable
39-
else:
40-
from pip._vendor.typing_extensions import (
41-
Literal,
42-
Protocol,
43-
runtime_checkable,
44-
) # pragma: no cover
45-
4640
from . import errors, themes
4741
from ._emoji_replace import _emoji_replace
4842
from ._export_format import CONSOLE_HTML_FORMAT, CONSOLE_SVG_FORMAT
@@ -739,6 +733,14 @@ def __init__(
739733
if no_color is not None
740734
else self._environ.get("NO_COLOR", "") != ""
741735
)
736+
if force_interactive is None:
737+
tty_interactive = self._environ.get("TTY_INTERACTIVE", None)
738+
if tty_interactive is not None:
739+
if tty_interactive == "0":
740+
force_interactive = False
741+
elif tty_interactive == "1":
742+
force_interactive = True
743+
742744
self.is_interactive = (
743745
(self.is_terminal and not self.is_dumb_terminal)
744746
if force_interactive is None
@@ -751,7 +753,7 @@ def __init__(
751753
)
752754
self._record_buffer: List[Segment] = []
753755
self._render_hooks: List[RenderHook] = []
754-
self._live: Optional["Live"] = None
756+
self._live_stack: List[Live] = []
755757
self._is_alt_screen = False
756758

757759
def __repr__(self) -> str:
@@ -823,24 +825,26 @@ def _exit_buffer(self) -> None:
823825
self._buffer_index -= 1
824826
self._check_buffer()
825827

826-
def set_live(self, live: "Live") -> None:
827-
"""Set Live instance. Used by Live context manager.
828+
def set_live(self, live: "Live") -> bool:
829+
"""Set Live instance. Used by Live context manager (no need to call directly).
828830
829831
Args:
830832
live (Live): Live instance using this Console.
831833
834+
Returns:
835+
Boolean that indicates if the live is the topmost of the stack.
836+
832837
Raises:
833838
errors.LiveError: If this Console has a Live context currently active.
834839
"""
835840
with self._lock:
836-
if self._live is not None:
837-
raise errors.LiveError("Only one live display may be active at once")
838-
self._live = live
841+
self._live_stack.append(live)
842+
return len(self._live_stack) == 1
839843

840844
def clear_live(self) -> None:
841-
"""Clear the Live instance."""
845+
"""Clear the Live instance. Used by the Live context manager (no need to call directly)."""
842846
with self._lock:
843-
self._live = None
847+
self._live_stack.pop()
844848

845849
def push_render_hook(self, hook: RenderHook) -> None:
846850
"""Add a new render hook to the stack.
@@ -992,12 +996,13 @@ def is_dumb_terminal(self) -> bool:
992996
@property
993997
def options(self) -> ConsoleOptions:
994998
"""Get default console options."""
999+
size = self.size
9951000
return ConsoleOptions(
996-
max_height=self.size.height,
997-
size=self.size,
1001+
max_height=size.height,
1002+
size=size,
9981003
legacy_windows=self.legacy_windows,
9991004
min_width=1,
1000-
max_width=self.width,
1005+
max_width=size.width,
10011006
encoding=self.encoding,
10021007
is_terminal=self.is_terminal,
10031008
)

src/pip/_vendor/rich/control.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
import sys
21
import time
3-
from typing import TYPE_CHECKING, Callable, Dict, Iterable, List, Union
4-
5-
if sys.version_info >= (3, 8):
6-
from typing import Final
7-
else:
8-
from pip._vendor.typing_extensions import Final # pragma: no cover
2+
from typing import TYPE_CHECKING, Callable, Dict, Iterable, List, Union, Final
93

104
from .segment import ControlCode, ControlType, Segment
115

src/pip/_vendor/rich/diagnose.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def report() -> None: # pragma: no cover
2626
"TERM_PROGRAM",
2727
"TERM",
2828
"TTY_COMPATIBLE",
29+
"TTY_INTERACTIVE",
2930
"VSCODE_VERBOSE_LOGGING",
3031
)
3132
env = {name: os.getenv(name) for name in env_names}

src/pip/_vendor/rich/emoji.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import sys
2-
from typing import TYPE_CHECKING, Optional, Union
2+
from typing import TYPE_CHECKING, Optional, Union, Literal
33

44
from .jupyter import JupyterMixin
55
from .segment import Segment
66
from .style import Style
77
from ._emoji_codes import EMOJI
88
from ._emoji_replace import _emoji_replace
99

10-
if sys.version_info >= (3, 8):
11-
from typing import Literal
12-
else:
13-
from pip._vendor.typing_extensions import Literal # pragma: no cover
14-
1510

1611
if TYPE_CHECKING:
1712
from .console import Console, ConsoleOptions, RenderResult

0 commit comments

Comments
 (0)