chore(pre-commit): update pre-commit hooks

This commit is contained in:
Xuehai Pan 2026-04-01 17:44:53 +08:00
parent 43015c916f
commit a6761eb5c4
5 changed files with 15 additions and 10 deletions

View file

@ -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: |

View file

@ -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()

View file

@ -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

View file

@ -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:

View file

@ -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]