mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
dvc: update precommit hooks (#5716)
* update pre-commit hooks * fix mypy errors 1. Casting `columns` to the custom Column with collapse. 2. Ignoring typedef difference for RichTable._collapse_widths. 3. Suppressing error with conditional paramiko imports https://github.com/python/mypy/issues/1153
This commit is contained in:
@@ -8,7 +8,7 @@ repos:
|
||||
- id: isort
|
||||
language_version: python3
|
||||
repo: https://github.com/timothycrosley/isort
|
||||
rev: 5.6.4
|
||||
rev: 5.8.0
|
||||
- hooks:
|
||||
- id: flake8
|
||||
language_version: python3
|
||||
@@ -18,13 +18,13 @@ repos:
|
||||
- flake8-debugger
|
||||
- flake8-string-format
|
||||
repo: https://gitlab.com/pycqa/flake8
|
||||
rev: 3.8.4
|
||||
rev: 3.9.0
|
||||
- hooks:
|
||||
- id: mypy
|
||||
language_version: python3
|
||||
files: ^dvc/
|
||||
repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: 'v0.790'
|
||||
rev: 'v0.812'
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: pylint
|
||||
|
||||
@@ -17,7 +17,7 @@ from ..base import RemoteCmdError
|
||||
try:
|
||||
import paramiko
|
||||
except ImportError:
|
||||
paramiko = None
|
||||
paramiko = None # type: ignore
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
+10
-8
@@ -1,5 +1,5 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING, List
|
||||
from typing import TYPE_CHECKING, List, cast
|
||||
|
||||
from rich.style import StyleType
|
||||
from rich.table import Column as RichColumn
|
||||
@@ -66,19 +66,20 @@ class Table(RichTable):
|
||||
"""
|
||||
widths = super()._calculate_column_widths(console, max_width)
|
||||
last_collapsed = -1
|
||||
for i in range(len(self.columns) - 1, -1, -1):
|
||||
if widths[i] == 1 and self.columns[i].collapse:
|
||||
columns = cast(List[Column], self.columns)
|
||||
for i in range(len(columns) - 1, -1, -1):
|
||||
if widths[i] == 1 and columns[i].collapse:
|
||||
if last_collapsed >= 0:
|
||||
del widths[last_collapsed]
|
||||
del self.columns[last_collapsed]
|
||||
del columns[last_collapsed]
|
||||
if self.box:
|
||||
max_width += 1
|
||||
for column in self.columns[last_collapsed:]:
|
||||
for column in columns[last_collapsed:]:
|
||||
column._index -= 1
|
||||
last_collapsed = i
|
||||
padding = self._get_padding_width(i)
|
||||
if (
|
||||
self.columns[i].overflow == "ellipsis"
|
||||
columns[i].overflow == "ellipsis"
|
||||
and (sum(widths) + padding) <= max_width
|
||||
):
|
||||
# Set content width to 1 (plus padding) if we can fit a
|
||||
@@ -88,7 +89,7 @@ class Table(RichTable):
|
||||
last_collapsed = -1
|
||||
return widths
|
||||
|
||||
def _collapse_widths(
|
||||
def _collapse_widths( # type: ignore[override]
|
||||
self, widths: List[int], wrapable: List[bool], max_width: int,
|
||||
) -> List[int]:
|
||||
"""Collapse columns right-to-left if possible to fit table into
|
||||
@@ -97,7 +98,8 @@ class Table(RichTable):
|
||||
If table is still too wide after collapsing, rich's automatic overflow
|
||||
handling will be used.
|
||||
"""
|
||||
collapsible = [column.collapse for column in self.columns]
|
||||
columns = cast(List[Column], self.columns)
|
||||
collapsible = [column.collapse for column in columns]
|
||||
total_width = sum(widths)
|
||||
excess_width = total_width - max_width
|
||||
if any(collapsible):
|
||||
|
||||
Reference in New Issue
Block a user