Skip to content

Commit

Permalink
chore(pre-commit): update pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Nov 24, 2024
1 parent a876f6e commit 93da21e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
13 changes: 1 addition & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion nvitop/api/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -2760,7 +2760,7 @@ def from_indices( # type: ignore[override]
- `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]
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 3 additions & 6 deletions nvitop/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
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__
Expand Down Expand Up @@ -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]]: ...


Expand All @@ -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]]: ...


Expand All @@ -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
Expand All @@ -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.
Expand Down
19 changes: 11 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -130,6 +126,7 @@ select = [
"F", # pyflakes
"N", # pep8-naming
"UP", # pyupgrade
"D", # pydocstyle
"ANN", # flake8-annotations
"S", # flake8-bandit
"BLE", # flake8-blind-except
Expand Down Expand Up @@ -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
Expand All @@ -175,29 +168,39 @@ 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]
"__init__.py" = [
"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

Expand Down

0 comments on commit 93da21e

Please # to comment.