From a6761eb5c4d4dad0dc0e3c1d00b5bd4dfd11828d Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Wed, 1 Apr 2026 17:44:53 +0800 Subject: [PATCH] chore(pre-commit): update pre-commit hooks --- .pre-commit-config.yaml | 2 +- nvitop/tui/library/history.py | 4 ++-- nvitop/tui/library/keybinding.py | 2 +- nvitop/tui/screens/metrics.py | 12 ++++++------ pyproject.toml | 5 +++++ 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8e58330..bb720ce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,7 +41,7 @@ repos: - id: codespell additional_dependencies: [".[toml]"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.19.1 + rev: v1.20.0 hooks: - id: mypy exclude: | diff --git a/nvitop/tui/library/history.py b/nvitop/tui/library/history.py index c7cfa92..96ebd19 100644 --- a/nvitop/tui/library/history.py +++ b/nvitop/tui/library/history.py @@ -233,7 +233,7 @@ class HistoryGraph: # pylint: disable=too-many-instance-attributes def add(self, value: float) -> None: if value is NA: # type: ignore[comparison-overlap] - value = self.baseline - 0.1 + value = self.baseline - 0.1 # type: ignore[unreachable] assert isinstance(value, (int, float)) with self.write_lock: @@ -368,7 +368,7 @@ class BufferedHistoryGraph(HistoryGraph): def add(self, value: float) -> None: if value is NA: # type: ignore[comparison-overlap] - value = self.baseline - 0.1 + value = self.baseline - 0.1 # type: ignore[unreachable] assert isinstance(value, (int, float)) timestamp = time.monotonic() diff --git a/nvitop/tui/library/keybinding.py b/nvitop/tui/library/keybinding.py index 8a31205..1991691 100644 --- a/nvitop/tui/library/keybinding.py +++ b/nvitop/tui/library/keybinding.py @@ -372,7 +372,7 @@ class KeyBuffer: # pylint: disable=too-many-instance-attributes and self.quantifier_key in self.keymap and self.keymap[self.quantifier_key] is self.QUANTIFIER_KEY_FINISHED # type: ignore[comparison-overlap] ): - self.finished_parsing_quantifier = True + self.finished_parsing_quantifier = True # type: ignore[unreachable] def clear(self) -> None: self.__init__(self.keymap) # type: ignore[misc] # pylint: disable=unnecessary-dunder-call diff --git a/nvitop/tui/screens/metrics.py b/nvitop/tui/screens/metrics.py index c58b3c0..3ed7b0f 100644 --- a/nvitop/tui/screens/metrics.py +++ b/nvitop/tui/screens/metrics.py @@ -152,17 +152,17 @@ class ProcessMetricsScreen(BaseSelectableScreen): # pylint: disable=too-many-in def format_cpu_percent(value: float) -> str: if value is NA: # type: ignore[comparison-overlap] - return f'CPU: {value}' + return f'CPU: {value}' # type: ignore[unreachable] return f'CPU: {value:.1f}%' def format_max_cpu_percent(value: float) -> str: if value is NA: # type: ignore[comparison-overlap] - return f'MAX CPU: {value}' + return f'MAX CPU: {value}' # type: ignore[unreachable] return f'MAX CPU: {value:.1f}%' def format_host_memory(value: float) -> str: if value is NA: # type: ignore[comparison-overlap] - return f'HOST-MEM: {value}' + return f'HOST-MEM: {value}' # type: ignore[unreachable] return ( f'HOST-MEM: {bytes2human(value)} ' f'({round(100.0 * value / total_host_memory, 1):.1f}%)' @@ -170,7 +170,7 @@ class ProcessMetricsScreen(BaseSelectableScreen): # pylint: disable=too-many-in def format_max_host_memory(value: float) -> str: if value is NA: # type: ignore[comparison-overlap] - return f'MAX HOST-MEM: {value}' + return f'MAX HOST-MEM: {value}' # type: ignore[unreachable] return ( f'MAX HOST-MEM: {bytes2human(value)} ' f'({round(100.0 * value / total_host_memory, 1):.1f}%) ' @@ -196,12 +196,12 @@ class ProcessMetricsScreen(BaseSelectableScreen): # pylint: disable=too-many-in def format_sm(value: float) -> str: if value is NA: # type: ignore[comparison-overlap] - return f'GPU-SM: {value}' + return f'GPU-SM: {value}' # type: ignore[unreachable] return f'GPU-SM: {value:.1f}%' def format_max_sm(value: float) -> str: if value is NA: # type: ignore[comparison-overlap] - return f'MAX GPU-SM: {value}' + return f'MAX GPU-SM: {value}' # type: ignore[unreachable] return f'MAX GPU-SM: {value:.1f}%' with self.snapshot_lock: diff --git a/pyproject.toml b/pyproject.toml index 1ecff3a..98dfb65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,6 +90,7 @@ warn_redundant_casts = true warn_unreachable = true warn_unused_configs = true warn_unused_ignores = true +no_site_packages = true [tool.pylint] main.py-version = "3.8" @@ -174,6 +175,9 @@ ignore = [ # TRY003: avoid specifying long messages outside the exception class # long messages are necessary for clarity "TRY003", + # FURB152: literals that are similar to constants in `math` module. + # change code semantics + "FURB152", ] [tool.ruff.lint.per-file-ignores] @@ -207,6 +211,7 @@ ignore = [ [tool.ruff.lint.isort] known-first-party = ["nvitop", "nvitop_exporter"] extra-standard-library = ["typing_extensions"] +known-local-folder = ["tests"] lines-after-imports = 2 [tool.ruff.lint.pydocstyle]