Skip to content

Commit 9490bdf

Browse files
committed
Upgrade rich to 14.0.0
1 parent 5bd617d commit 9490bdf

File tree

9 files changed

+164
-60
lines changed

9 files changed

+164
-60
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.0.0

src/pip/_vendor/rich/console.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def group(fit: bool = True) -> Callable[..., Callable[..., Group]]:
500500
"""
501501

502502
def decorator(
503-
method: Callable[..., Iterable[RenderableType]]
503+
method: Callable[..., Iterable[RenderableType]],
504504
) -> Callable[..., Group]:
505505
"""Convert a method that returns an iterable of renderables in to a Group."""
506506

@@ -735,7 +735,9 @@ def __init__(
735735
self.get_time = get_time or monotonic
736736
self.style = style
737737
self.no_color = (
738-
no_color if no_color is not None else "NO_COLOR" in self._environ
738+
no_color
739+
if no_color is not None
740+
else self._environ.get("NO_COLOR", "") != ""
739741
)
740742
self.is_interactive = (
741743
(self.is_terminal and not self.is_dumb_terminal)
@@ -933,11 +935,13 @@ def is_terminal(self) -> bool:
933935
934936
Returns:
935937
bool: True if the console writing to a device capable of
936-
understanding terminal codes, otherwise False.
938+
understanding escape sequences, otherwise False.
937939
"""
940+
# If dev has explicitly set this value, return it
938941
if self._force_terminal is not None:
939942
return self._force_terminal
940943

944+
# Fudge for Idle
941945
if hasattr(sys.stdin, "__module__") and sys.stdin.__module__.startswith(
942946
"idlelib"
943947
):
@@ -948,12 +952,22 @@ def is_terminal(self) -> bool:
948952
# return False for Jupyter, which may have FORCE_COLOR set
949953
return False
950954

951-
# If FORCE_COLOR env var has any value at all, we assume a terminal.
952-
force_color = self._environ.get("FORCE_COLOR")
953-
if force_color is not None:
954-
self._force_terminal = True
955+
environ = self._environ
956+
957+
tty_compatible = environ.get("TTY_COMPATIBLE", "")
958+
# 0 indicates device is not tty compatible
959+
if tty_compatible == "0":
960+
return False
961+
# 1 indicates device is tty compatible
962+
if tty_compatible == "1":
955963
return True
956964

965+
# https://force-color.org/
966+
force_color = environ.get("FORCE_COLOR")
967+
if force_color is not None:
968+
return force_color != ""
969+
970+
# Any other value defaults to auto detect
957971
isatty: Optional[Callable[[], bool]] = getattr(self.file, "isatty", None)
958972
try:
959973
return False if isatty is None else isatty()

src/pip/_vendor/rich/default_styles.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@
120120
"traceback.exc_type": Style(color="bright_red", bold=True),
121121
"traceback.exc_value": Style.null(),
122122
"traceback.offset": Style(color="bright_red", bold=True),
123-
"traceback.error_range": Style(underline=True, bold=True, dim=False),
123+
"traceback.error_range": Style(underline=True, bold=True),
124+
"traceback.note": Style(color="green", bold=True),
125+
"traceback.group.border": Style(color="magenta"),
124126
"bar.back": Style(color="grey23"),
125127
"bar.complete": Style(color="rgb(249,38,114)"),
126128
"bar.finished": Style(color="rgb(114,156,31)"),

src/pip/_vendor/rich/diagnose.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ def report() -> None: # pragma: no cover
1515
inspect(features)
1616

1717
env_names = (
18-
"TERM",
19-
"COLORTERM",
2018
"CLICOLOR",
21-
"NO_COLOR",
22-
"TERM_PROGRAM",
19+
"COLORTERM",
2320
"COLUMNS",
24-
"LINES",
21+
"JPY_PARENT_PID",
2522
"JUPYTER_COLUMNS",
2623
"JUPYTER_LINES",
27-
"JPY_PARENT_PID",
24+
"LINES",
25+
"NO_COLOR",
26+
"TERM_PROGRAM",
27+
"TERM",
28+
"TTY_COMPATIBLE",
2829
"VSCODE_VERBOSE_LOGGING",
2930
)
3031
env = {name: os.getenv(name) for name in env_names}

src/pip/_vendor/rich/panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Panel(JupyterMixin):
2222
2323
Args:
2424
renderable (RenderableType): A console renderable object.
25-
box (Box, optional): A Box instance that defines the look of the border (see :ref:`appendix_box`. Defaults to box.ROUNDED.
25+
box (Box): A Box instance that defines the look of the border (see :ref:`appendix_box`. Defaults to box.ROUNDED.
2626
title (Optional[TextType], optional): Optional title displayed in panel header. Defaults to None.
2727
title_align (AlignMethod, optional): Alignment of title. Defaults to "center".
2828
subtitle (Optional[TextType], optional): Optional subtitle displayed in panel footer. Defaults to None.

src/pip/_vendor/rich/style.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def parse(cls, style_definition: str) -> "Style":
524524
if not word:
525525
raise errors.StyleSyntaxError("color expected after 'on'")
526526
try:
527-
Color.parse(word) is None
527+
Color.parse(word)
528528
except ColorParseError as error:
529529
raise errors.StyleSyntaxError(
530530
f"unable to parse {word!r} as background color; {error}"

src/pip/_vendor/rich/table.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,6 @@ def align_cell(
929929
if __name__ == "__main__": # pragma: no cover
930930
from pip._vendor.rich.console import Console
931931
from pip._vendor.rich.highlighter import ReprHighlighter
932-
from pip._vendor.rich.table import Table as Table
933932

934933
from ._timer import timer
935934

0 commit comments

Comments
 (0)