From 623b1e536096927654354e5602141ffa278c3c36 Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Wed, 31 Jul 2024 15:36:15 +0800 Subject: [PATCH] chore(pre-commit): update pre-commit hooks --- .pre-commit-config.yaml | 4 ++-- nvitop-exporter/setup.py | 2 +- nvitop/api/collector.py | 2 +- nvitop/api/device.py | 4 ++-- nvitop/api/process.py | 4 ++-- nvitop/api/utils.py | 2 +- pyproject.toml | 2 +- setup.py | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8ac1e601..45e74d37 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: - id: debug-statements - id: double-quote-string-fixer - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.1 + rev: v0.5.5 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -38,7 +38,7 @@ repos: hooks: - id: black - repo: https://github.com/asottile/pyupgrade - rev: v3.16.0 + rev: v3.17.0 hooks: - id: pyupgrade args: [--py37-plus] # sync with requires-python diff --git a/nvitop-exporter/setup.py b/nvitop-exporter/setup.py index 01b096ed..518c5a86 100755 --- a/nvitop-exporter/setup.py +++ b/nvitop-exporter/setup.py @@ -22,7 +22,7 @@ @contextlib.contextmanager -def vcs_version(name: str, path: Path | str) -> Generator[ModuleType, None, None]: +def vcs_version(name: str, path: Path | str) -> Generator[ModuleType]: """Context manager to update version string in a version module.""" path = Path(path).absolute() assert path.is_file() diff --git a/nvitop/api/collector.py b/nvitop/api/collector.py index ad5ac75d..ddd4f7c7 100644 --- a/nvitop/api/collector.py +++ b/nvitop/api/collector.py @@ -515,7 +515,7 @@ def deactivate(self, tag: str | None = None) -> ResourceMetricCollector: stop = deactivate @contextlib.contextmanager - def context(self, tag: str) -> Generator[ResourceMetricCollector, None, None]: + def context(self, tag: str) -> Generator[ResourceMetricCollector]: """A context manager for starting and stopping resource metric collection. Args: diff --git a/nvitop/api/device.py b/nvitop/api/device.py index 6b56693c..f1282de4 100644 --- a/nvitop/api/device.py +++ b/nvitop/api/device.py @@ -2324,7 +2324,7 @@ def as_snapshot(self) -> Snapshot: # Modified from psutil (https://github.com/giampaolo/psutil) @contextlib.contextmanager - def oneshot(self) -> Generator[None, None, None]: + def oneshot(self) -> Generator[None]: """A utility context manager which considerably speeds up the retrieval of multiple device information at the same time. Internally different device info (e.g. memory_info, utilization_rates, ...) may be fetched @@ -3080,7 +3080,7 @@ def _does_any_device_support_mig_mode(uuids: Iterable[str] | None = None) -> boo @contextlib.contextmanager -def _global_physical_device(device: PhysicalDevice) -> Generator[PhysicalDevice, None, None]: +def _global_physical_device(device: PhysicalDevice) -> Generator[PhysicalDevice]: global _GLOBAL_PHYSICAL_DEVICE # pylint: disable=global-statement with _GLOBAL_PHYSICAL_DEVICE_LOCK: diff --git a/nvitop/api/process.py b/nvitop/api/process.py index ea086b76..dfae15a8 100644 --- a/nvitop/api/process.py +++ b/nvitop/api/process.py @@ -384,7 +384,7 @@ def children(self, recursive: bool = False) -> list[HostProcess]: return [HostProcess(child.pid) for child in super().children(recursive)] @contextlib.contextmanager - def oneshot(self) -> Generator[None, None, None]: + def oneshot(self) -> Generator[None]: """A utility context manager which considerably speeds up the retrieval of multiple process information at the same time. Internally different process info (e.g. name, ppid, uids, gids, ...) may be fetched by using @@ -1026,7 +1026,7 @@ def take_snapshots( # batched version of `as_snapshot` @classmethod @contextlib.contextmanager - def failsafe(cls) -> Generator[None, None, None]: + def failsafe(cls) -> Generator[None]: """A context manager that enables fallback values for methods that fail. Examples: diff --git a/nvitop/api/utils.py b/nvitop/api/utils.py index ac5f6248..6f19ce9a 100644 --- a/nvitop/api/utils.py +++ b/nvitop/api/utils.py @@ -707,7 +707,7 @@ def __setitem__(self, name: str, value: Any) -> None: def __iter__(self) -> Iterator[str]: """Support ``for name in snapshot`` syntax and ``*`` tuple unpack ``[*snapshot]`` syntax.""" - def gen() -> Generator[str, None, None]: + def gen() -> Generator[str]: yield from (name for name in self.__dict__ if name not in {'real', 'timestamp'}) return gen() diff --git a/pyproject.toml b/pyproject.toml index 1f8d5dfe..416f7da7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,7 +108,7 @@ warn_unused_ignores = true [[tool.mypy.overrides]] module = ['nvitop.callbacks.*', 'nvitop.gui.*'] -ignore_errors= true +ignore_errors = true [tool.pydocstyle] convention = "google" diff --git a/setup.py b/setup.py index 0af1cf6f..22d97d77 100755 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ @contextlib.contextmanager -def vcs_version(name: str, path: Path | str) -> Generator[ModuleType, None, None]: +def vcs_version(name: str, path: Path | str) -> Generator[ModuleType]: """Context manager to update version string in a version module.""" path = Path(path).absolute() assert path.is_file()