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:
Alex Lopez
2021-03-30 20:57:40 +03:00
committed by GitHub
parent 09cb495423
commit 4e7f924e8b
3 changed files with 9 additions and 6 deletions
+3 -1
View File
@@ -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
View File
@@ -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
+1 -1
View File
@@ -83,7 +83,7 @@ install_requires = [
"pygtrie==2.3.2",
"dpath>=2.0.1,<3",
"shtab>=1.3.4,<2",
"rich>=9.0.0,<10",
"rich>=10.0.0",
"dictdiffer>=0.8.1",
"python-benedict>=0.21.1",
"pyparsing==2.4.7",