From 3bc4869f8ba56ca731ea6f4f66d4b2c26792dfc5 Mon Sep 17 00:00:00 2001 From: Martin Hoyer Date: Thu, 31 Oct 2024 17:04:10 +0100 Subject: [PATCH] Fix and update pre-commit ruf check --- .pre-commit-config.yaml | 4 ++-- rtslib/tcm.py | 6 +++--- rtslib/utils.py | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 209c747..a0e101f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.6.4 + rev: v0.7.1 hooks: - id: ruff args: [--fix] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-case-conflict - id: check-ast diff --git a/rtslib/tcm.py b/rtslib/tcm.py index a9176e7..9d31191 100644 --- a/rtslib/tcm.py +++ b/rtslib/tcm.py @@ -1005,9 +1005,9 @@ def __init__(self, name, storage_object_cls, mode, index=None): with lock_file_path.open('w+') as lkfd: fcntl.flock(lkfd, fcntl.LOCK_EX) indexes = set(bs_cache.values()) - for index in range(1048576): - if index not in indexes: - self._index = index + for i in range(1048576): + if i not in indexes: + self._index = i bs_cache[self._lookup_key] = self._index break else: diff --git a/rtslib/utils.py b/rtslib/utils.py index ef2ae12..d3a93ae 100644 --- a/rtslib/utils.py +++ b/rtslib/utils.py @@ -115,10 +115,8 @@ def is_dev_in_use(path): except OSError: return True else: - try: + with suppress(OSError): os.close(file_fd) - except OSError: - pass return False def _get_size_for_dev(device):