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):