diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b56f308..fd19592 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/charliermarsh/ruff-pre-commit - rev: v0.0.263 + rev: v0.0.265 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.3.2 + rev: v3.4.0 hooks: - id: pyupgrade args: [--py37-plus] # sync with requires-python diff --git a/nvitop/api/utils.py b/nvitop/api/utils.py index f9890ea..12d8782 100644 --- a/nvitop/api/utils.py +++ b/nvitop/api/utils.py @@ -27,6 +27,7 @@ import os import re import sys import time +from collections.abc import KeysView from typing import Any, Callable, Generator, Iterable, Iterator from psutil import WINDOWS @@ -698,10 +699,10 @@ class Snapshot: return gen() - def keys(self) -> Iterator[str]: + def keys(self) -> Iterable[str]: # pylint: disable-next=line-too-long """Support ``**`` dictionary unpack ``{**snapshot}`` / ``dict(**snapshot)`` syntax and ``dict(snapshot)`` dictionary conversion.""" - return iter(self) + return KeysView(self) # type: ignore[arg-type] # Modified from psutil (https://github.com/giampaolo/psutil)