diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 55a11e2212..2329a5f062 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/dvc/fs/ssh/connection.py b/dvc/fs/ssh/connection.py index 6374a9c42c..5a8c5905da 100644 --- a/dvc/fs/ssh/connection.py +++ b/dvc/fs/ssh/connection.py @@ -17,7 +17,7 @@ try: import paramiko except ImportError: - paramiko = None + paramiko = None # type: ignore logger = logging.getLogger(__name__) diff --git a/dvc/utils/table.py b/dvc/utils/table.py index 61363f2b65..e3a84c00a6 100644 --- a/dvc/utils/table.py +++ b/dvc/utils/table.py @@ -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 @@ def _calculate_column_widths( """ 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 @@ def _calculate_column_widths( 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 @@ def _collapse_widths( 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):