mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 07:18:27 +01:00
dvc: fix breakage with rich==10.0.0 (#5733)
* dvc: fix breakage with rich==10.0.0 Change in the arguments of __rich_measure__. Fixes #5722 * dvc: Fix linting breakage from rich==10.0.0 Fixes: #5733 * dvc: set lower bound for rich dependency to 10.0.0 Fixes #5722
This commit is contained in:
@@ -408,7 +408,9 @@ class CmdExperimentsShow(CmdBase):
|
||||
# NOTE: rich does not have native support for unlimited width
|
||||
# via pager. we override rich table compression by setting
|
||||
# console width to the full width of the table
|
||||
measurement = table.__rich_measure__(console, SHOW_MAX_WIDTH)
|
||||
console_options = console.options
|
||||
console_options.max_width = SHOW_MAX_WIDTH
|
||||
measurement = table.__rich_measure__(console, console_options)
|
||||
console._width = ( # pylint: disable=protected-access
|
||||
measurement.maximum
|
||||
)
|
||||
|
||||
+5
-4
@@ -8,6 +8,7 @@ from rich.table import Table as RichTable
|
||||
if TYPE_CHECKING:
|
||||
from rich.console import (
|
||||
Console,
|
||||
ConsoleOptions,
|
||||
JustifyMethod,
|
||||
OverflowMethod,
|
||||
RenderableType,
|
||||
@@ -56,7 +57,7 @@ class Table(RichTable):
|
||||
self.columns.append(column)
|
||||
|
||||
def _calculate_column_widths(
|
||||
self, console: "Console", max_width: int
|
||||
self, console: "Console", options: "ConsoleOptions"
|
||||
) -> List[int]:
|
||||
"""Calculate the widths of each column, including padding, not
|
||||
including borders.
|
||||
@@ -64,7 +65,7 @@ class Table(RichTable):
|
||||
Adjacent collapsed columns will be removed until there is only a single
|
||||
truncated column remaining.
|
||||
"""
|
||||
widths = super()._calculate_column_widths(console, max_width)
|
||||
widths = super()._calculate_column_widths(console, options)
|
||||
last_collapsed = -1
|
||||
columns = cast(List[Column], self.columns)
|
||||
for i in range(len(columns) - 1, -1, -1):
|
||||
@@ -73,14 +74,14 @@ class Table(RichTable):
|
||||
del widths[last_collapsed]
|
||||
del columns[last_collapsed]
|
||||
if self.box:
|
||||
max_width += 1
|
||||
options.max_width += 1
|
||||
for column in columns[last_collapsed:]:
|
||||
column._index -= 1
|
||||
last_collapsed = i
|
||||
padding = self._get_padding_width(i)
|
||||
if (
|
||||
columns[i].overflow == "ellipsis"
|
||||
and (sum(widths) + padding) <= max_width
|
||||
and (sum(widths) + padding) <= options.max_width
|
||||
):
|
||||
# Set content width to 1 (plus padding) if we can fit a
|
||||
# single unicode ellipsis in this column
|
||||
|
||||
Reference in New Issue
Block a user