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

This commit is contained in:
Xuehai Pan 2024-11-25 01:28:41 +08:00
parent a876f6e711
commit 93da21e171
4 changed files with 18 additions and 27 deletions

View file

@ -25,7 +25,7 @@ repos:
- id: debug-statements
- id: double-quote-string-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
@ -69,17 +69,6 @@ repos:
language: system
types: [python]
require_serial: true
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies: [".[toml]"]
exclude: |
(?x)(
^nvitop/gui/|
^nvitop/callbacks/|
^docs/
)
- repo: local
hooks:
- id: mypy

View file

@ -2760,7 +2760,7 @@ class CudaDevice(Device):
- `CUDA Device Enumeration for MIG Device <https://docs.nvidia.com/datacenter/tesla/mig-user-guide/index.html#cuda-visible-devices>`_
Args:
cuda_indices (Iterable[int]):
indices (Iterable[int]):
The indices of the GPU in CUDA ordinal, if not given, returns all visible CUDA devices.
Returns: List[CudaDevice]
@ -3251,6 +3251,8 @@ def _parse_cuda_visible_devices_to_uuids(
The value of the ``CUDA_VISIBLE_DEVICES`` variable. If not given, the value from the
environment will be used. If explicitly given by :data:`None`, the ``CUDA_VISIBLE_DEVICES``
environment variable will be unset before parsing.
verbose (bool):
Whether to raise an exception in the subprocess if failed to parse the ``CUDA_VISIBLE_DEVICES``.
Returns: List[str]
A list of device UUIDs without ``GPU-`` or ``MIG-`` prefixes.

View file

@ -62,7 +62,7 @@ import math
import os
import sys
import warnings
from typing import TYPE_CHECKING, Any, Callable, Iterable, Sequence, overload
from typing import TYPE_CHECKING, Callable, Iterable, Sequence, overload
from nvitop.api import Device, GpuProcess, Snapshot, colored, host, human2bytes, libnvml
from nvitop.version import __version__
@ -90,7 +90,6 @@ def select_devices( # pylint: disable=too-many-arguments
tolerance: int,
free_accounts: list[str] | None,
sort: bool,
**kwargs: Any,
) -> list[int] | list[tuple[int, int]]: ...
@ -109,7 +108,6 @@ def select_devices( # pylint: disable=too-many-arguments
tolerance: int,
free_accounts: list[str] | None,
sort: bool,
**kwargs: Any,
) -> list[int] | list[tuple[int, int]]: ...
@ -128,11 +126,11 @@ def select_devices( # pylint: disable=too-many-arguments
tolerance: int,
free_accounts: list[str] | None,
sort: bool,
**kwargs: Any,
) -> list[Device]: ...
def select_devices( # pylint: disable=too-many-branches,too-many-statements,too-many-locals,unused-argument,too-many-arguments
# pylint: disable-next=too-many-branches,too-many-statements,too-many-locals,unused-argument,too-many-arguments
def select_devices(
devices: Iterable[Device] | None = None,
*,
format: Literal['index', 'uuid', 'device'] = 'index', # pylint: disable=redefined-builtin
@ -146,7 +144,6 @@ def select_devices( # pylint: disable=too-many-branches,too-many-statements,too
tolerance: int = 0, # in percentage
free_accounts: list[str] | None = None,
sort: bool = True,
**kwargs: Any,
) -> list[int] | list[tuple[int, int]] | list[str] | list[Device]:
"""Select a subset of devices satisfying the specified criteria.

View file

@ -110,10 +110,6 @@ warn_unused_ignores = true
module = ['nvitop.callbacks.*', 'nvitop.gui.*']
ignore_errors = true
[tool.pydocstyle]
convention = "google"
match-dir = '^(?!(gui|callbacks|docs))[^\.].*'
[tool.codespell]
ignore-words = "docs/source/spelling_wordlist.txt"
@ -130,6 +126,7 @@ select = [
"F", # pyflakes
"N", # pep8-naming
"UP", # pyupgrade
"D", # pydocstyle
"ANN", # flake8-annotations
"S", # flake8-bandit
"BLE", # flake8-blind-except
@ -160,10 +157,6 @@ ignore = [
# too long docstring due to long example blocks
"E501",
"W505",
# ANN101: missing type annotation for `self` in method
# ANN102: missing type annotation for `cls` in classmethod
"ANN101",
"ANN102",
# ANN401: dynamically typed expressions (typing.Any) are disallowed
"ANN401",
# S101: use of `assert` detected
@ -175,6 +168,9 @@ ignore = [
# TRY003: avoid specifying long messages outside the exception class
# long messages are necessary for clarity
"TRY003",
# RUF022: `__all__` is not ordered according to an "isort-style" sort
# `__all__` contains comments to group names
"RUF022",
]
[tool.ruff.lint.per-file-ignores]
@ -182,22 +178,29 @@ ignore = [
"F401", # unused-import
]
"setup.py" = [
"D", # pydocstyle
"ANN", # flake8-annotations
]
"nvitop/api/lib*.py" = [
"N", # pep8-naming
]
"nvitop/callbacks/*.py" = [
"D", # pydocstyle
"ANN", # flake8-annotations
]
"nvitop/gui/**/*.py" = [
"D", # pydocstyle
"ANN", # flake8-annotations
"RUF012", # mutable-class-default
]
"docs/source/conf.py" = [
"D", # pydocstyle
"INP001", # flake8-no-pep420
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true