Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-filelock for openSUSE:Factory checked in at 2023-06-12 15:24:53 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-filelock (Old) and /work/SRC/openSUSE:Factory/.python-filelock.new.15902 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-filelock" Mon Jun 12 15:24:53 2023 rev:13 rq:1092285 version:3.12.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-filelock/python-filelock.changes 2023-04-29 17:27:35.646404889 +0200 +++ /work/SRC/openSUSE:Factory/.python-filelock.new.15902/python-filelock.changes 2023-06-12 15:25:19.706653374 +0200 @@ -1,0 +2,7 @@ +Sun Jun 11 12:40:08 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 3.12.1: + * Add 3.12 support + * Fix test_bad_lock_file for other OSes + +------------------------------------------------------------------- Old: ---- filelock-3.12.0.tar.gz New: ---- filelock-3.12.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-filelock.spec ++++++ --- /var/tmp/diff_new_pack.BydPba/_old 2023-06-12 15:25:20.342657137 +0200 +++ /var/tmp/diff_new_pack.BydPba/_new 2023-06-12 15:25:20.346657161 +0200 @@ -19,7 +19,7 @@ %{?sle15_python_module_pythons} Name: python-filelock -Version: 3.12.0 +Version: 3.12.1 Release: 0 Summary: Platform Independent File Lock in Python License: Unlicense @@ -28,8 +28,8 @@ BuildRequires: %{python_module hatch_vcs} BuildRequires: %{python_module hatchling} BuildRequires: %{python_module pip} -BuildRequires: %{python_module pytest} BuildRequires: %{python_module pytest-mock} +BuildRequires: %{python_module pytest} BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros ++++++ filelock-3.12.0.tar.gz -> filelock-3.12.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/PKG-INFO new/filelock-3.12.1/PKG-INFO --- old/filelock-3.12.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: filelock -Version: 3.12.0 +Version: 3.12.1 Summary: A platform independent file lock. Project-URL: Documentation, https://py-filelock.readthedocs.io Project-URL: Homepage, https://github.com/tox-dev/py-filelock @@ -15,21 +15,26 @@ Classifier: License :: OSI Approved :: The Unlicense (Unlicense) Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 +Classifier: Programming Language :: Python :: 3.12 Classifier: Topic :: Internet Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: System Requires-Python: >=3.7 Provides-Extra: docs -Requires-Dist: furo>=2023.3.27; extra == 'docs' +Requires-Dist: furo>=2023.5.20; extra == 'docs' Requires-Dist: sphinx-autodoc-typehints!=1.23.4,>=1.23; extra == 'docs' -Requires-Dist: sphinx>=6.1.3; extra == 'docs' +Requires-Dist: sphinx>=7.0.1; extra == 'docs' Provides-Extra: testing Requires-Dist: covdefaults>=2.3; extra == 'testing' -Requires-Dist: coverage>=7.2.3; extra == 'testing' +Requires-Dist: coverage>=7.2.7; extra == 'testing' Requires-Dist: diff-cover>=7.5; extra == 'testing' -Requires-Dist: pytest-cov>=4; extra == 'testing' +Requires-Dist: pytest-cov>=4.1; extra == 'testing' Requires-Dist: pytest-mock>=3.10; extra == 'testing' Requires-Dist: pytest-timeout>=2.1; extra == 'testing' Requires-Dist: pytest>=7.3.1; extra == 'testing' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/pyproject.toml new/filelock-3.12.1/pyproject.toml --- old/filelock-3.12.0/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 @@ -2,7 +2,7 @@ build-backend = "hatchling.build" requires = [ "hatch-vcs>=0.3", - "hatchling>=1.14", + "hatchling>=1.17.1", ] [project] @@ -25,8 +25,13 @@ "License :: OSI Approved :: The Unlicense (Unlicense)", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Internet", "Topic :: Software Development :: Libraries", "Topic :: System", @@ -35,16 +40,16 @@ "version", ] optional-dependencies.docs = [ - "furo>=2023.3.27", - "sphinx>=6.1.3", + "furo>=2023.5.20", + "sphinx>=7.0.1", "sphinx-autodoc-typehints!=1.23.4,>=1.23", ] optional-dependencies.testing = [ "covdefaults>=2.3", - "coverage>=7.2.3", + "coverage>=7.2.7", "diff-cover>=7.5", "pytest>=7.3.1", - "pytest-cov>=4", + "pytest-cov>=4.1", "pytest-mock>=3.10", "pytest-timeout>=2.1", ] @@ -61,18 +66,6 @@ [tool.black] line-length = 120 -[tool.isort] -profile = "black" -known_first_party = ["filelock"] -add_imports = ["from __future__ import annotations"] - -[tool.flake8] -max-complexity = 22 -max-line-length = 120 -unused-arguments-ignore-abstract-functions = true -noqa-require-code = true -dictionaries = ["en_US", "python", "technical", "django"] - [tool.coverage] html.show_contexts = true html.skip_covered = false @@ -88,5 +81,26 @@ strict = true overrides = [{ module = ["appdirs.*", "jnius.*"], ignore_missing_imports = true }] -[tool.pep8] -max-line-length = "120" +[tool.ruff] +select = ["ALL"] +line-length = 120 +target-version = "py37" +isort = {known-first-party = ["platformdirs", "tests"], required-imports = ["from __future__ import annotations"]} +ignore = [ + "ANN101", # Missing type annotation for `self` in method + "D301", # Use `r"""` if any backslashes in a docstring + "D205", # 1 blank line required between summary line and description + "D401", # First line of docstring should be in imperative mood + "D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible + "D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible + "S104", # Possible binding to all interface +] +[tool.ruff.per-file-ignores] +"tests/**/*.py" = [ + "S101", # asserts allowed in tests... + "FBT", # don"t care about booleans as positional arguments in tests + "INP001", # no implicit namespace + "D", # don"t care about documentation in tests + "S603", # `subprocess` call: check for execution of untrusted input + "PLR2004", # Magic value used in comparison, consider replacing with a constant variable +] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/src/filelock/__init__.py new/filelock-3.12.1/src/filelock/__init__.py --- old/filelock-3.12.0/src/filelock/__init__.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/src/filelock/__init__.py 2020-02-02 01:00:00.000000000 +0100 @@ -25,18 +25,16 @@ if sys.platform == "win32": # pragma: win32 cover _FileLock: type[BaseFileLock] = WindowsFileLock else: # pragma: win32 no cover - if has_fcntl: + if has_fcntl: # noqa: PLR5501 _FileLock: type[BaseFileLock] = UnixFileLock else: _FileLock = SoftFileLock if warnings is not None: warnings.warn("only soft file lock is available", stacklevel=2) -if TYPE_CHECKING: - FileLock = SoftFileLock -else: - #: Alias for the lock, which should be used for the current platform. - FileLock = _FileLock + +#: Alias for the lock, which should be used for the current platform. +FileLock: type[BaseFileLock] = SoftFileLock if TYPE_CHECKING else _FileLock # type: ignore[assignment] __all__ = [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/src/filelock/_api.py new/filelock-3.12.1/src/filelock/_api.py --- old/filelock-3.12.0/src/filelock/_api.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/src/filelock/_api.py 2020-02-02 01:00:00.000000000 +0100 @@ -8,11 +8,13 @@ from abc import ABC, abstractmethod from dataclasses import dataclass from threading import local -from types import TracebackType -from typing import Any +from typing import TYPE_CHECKING, Any from ._error import Timeout +if TYPE_CHECKING: + from types import TracebackType + _LOGGER = logging.getLogger("filelock") @@ -30,18 +32,16 @@ def __exit__( self, - exc_type: type[BaseException] | None, # noqa: U100 - exc_value: BaseException | None, # noqa: U100 - traceback: TracebackType | None, # noqa: U100 + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: TracebackType | None, ) -> None: self.lock.release() @dataclass class FileLockContext: - """ - A dataclass which holds the context for a ``BaseFileLock`` object. - """ + """A dataclass which holds the context for a ``BaseFileLock`` object.""" # The context is held in a separate class to allow optional use of thread local storage via the # ThreadLocalFileContext class. @@ -63,9 +63,7 @@ class ThreadLocalFileContext(FileLockContext, local): - """ - A thread local version of the ``FileLockContext`` class. - """ + """A thread local version of the ``FileLockContext`` class.""" class BaseFileLock(ABC, contextlib.ContextDecorator): @@ -76,7 +74,7 @@ lock_file: str | os.PathLike[Any], timeout: float = -1, mode: int = 0o644, - thread_local: bool = True, + thread_local: bool = True, # noqa: FBT001, FBT002 ) -> None: """ Create a new lock object. @@ -151,9 +149,7 @@ @property def lock_counter(self) -> int: - """ - :return: The number of times this lock has been acquired (but not yet released). - """ + """:return: The number of times this lock has been acquired (but not yet released).""" return self._context.lock_counter def acquire( @@ -218,22 +214,21 @@ if self.is_locked: _LOGGER.debug("Lock %s acquired on %s", lock_id, lock_filename) break - elif blocking is False: + if blocking is False: _LOGGER.debug("Failed to immediately acquire lock %s on %s", lock_id, lock_filename) - raise Timeout(lock_filename) - elif 0 <= timeout < time.perf_counter() - start_time: + raise Timeout(lock_filename) # noqa: TRY301 + if 0 <= timeout < time.perf_counter() - start_time: _LOGGER.debug("Timeout on acquiring lock %s on %s", lock_id, lock_filename) - raise Timeout(lock_filename) - else: - msg = "Lock %s not acquired on %s, waiting %s seconds ..." - _LOGGER.debug(msg, lock_id, lock_filename, poll_interval) - time.sleep(poll_interval) + raise Timeout(lock_filename) # noqa: TRY301 + msg = "Lock %s not acquired on %s, waiting %s seconds ..." + _LOGGER.debug(msg, lock_id, lock_filename, poll_interval) + time.sleep(poll_interval) except BaseException: # Something did go wrong, so decrement the counter. self._context.lock_counter = max(0, self._context.lock_counter - 1) raise return AcquireReturnProxy(lock=self) - def release(self, force: bool = False) -> None: + def release(self, force: bool = False) -> None: # noqa: FBT001, FBT002 """ Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. Also note, that the lock file itself is not automatically deleted. @@ -262,9 +257,9 @@ def __exit__( self, - exc_type: type[BaseException] | None, # noqa: U100 - exc_value: BaseException | None, # noqa: U100 - traceback: TracebackType | None, # noqa: U100 + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: TracebackType | None, ) -> None: """ Release the lock. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/src/filelock/_error.py new/filelock-3.12.1/src/filelock/_error.py --- old/filelock-3.12.0/src/filelock/_error.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/src/filelock/_error.py 2020-02-02 01:00:00.000000000 +0100 @@ -3,7 +3,7 @@ from typing import Any -class Timeout(TimeoutError): +class Timeout(TimeoutError): # noqa: N818 """Raised when the lock could not be acquired in *timeout* seconds.""" def __init__(self, lock_file: str) -> None: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/src/filelock/_soft.py new/filelock-3.12.1/src/filelock/_soft.py --- old/filelock-3.12.0/src/filelock/_soft.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/src/filelock/_soft.py 2020-02-02 01:00:00.000000000 +0100 @@ -2,7 +2,9 @@ import os import sys +from contextlib import suppress from errno import EACCES, EEXIST +from pathlib import Path from ._api import BaseFileLock from ._util import raise_on_not_writable_file @@ -32,12 +34,11 @@ self._context.lock_file_fd = file_handler def _release(self) -> None: - os.close(self._context.lock_file_fd) # type: ignore # the lock file is definitely not None + assert self._context.lock_file_fd is not None # noqa: S101 + os.close(self._context.lock_file_fd) # the lock file is definitely not None self._context.lock_file_fd = None - try: - os.remove(self.lock_file) - except OSError: # the file is already deleted and that's what we want - pass + with suppress(OSError): # the file is already deleted and that's what we want + Path(self.lock_file).unlink() __all__ = [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/src/filelock/_unix.py new/filelock-3.12.1/src/filelock/_unix.py --- old/filelock-3.12.0/src/filelock/_unix.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/src/filelock/_unix.py 2020-02-02 01:00:00.000000000 +0100 @@ -2,6 +2,7 @@ import os import sys +from contextlib import suppress from errno import ENOSYS from typing import cast @@ -34,16 +35,15 @@ def _acquire(self) -> None: open_flags = os.O_RDWR | os.O_CREAT | os.O_TRUNC fd = os.open(self.lock_file, open_flags, self._context.mode) - try: + with suppress(PermissionError): # This locked is not owned by this UID os.fchmod(fd, self._context.mode) - except PermissionError: - pass # This locked is not owned by this UID try: fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB) except OSError as exception: os.close(fd) if exception.errno == ENOSYS: # NotImplemented error - raise NotImplementedError("FileSystem does not appear to support flock; user SoftFileLock instead") + msg = "FileSystem does not appear to support flock; user SoftFileLock instead" + raise NotImplementedError(msg) from exception else: self._context.lock_file_fd = fd diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/src/filelock/_util.py new/filelock-3.12.1/src/filelock/_util.py --- old/filelock-3.12.0/src/filelock/_util.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/src/filelock/_util.py 2020-02-02 01:00:00.000000000 +0100 @@ -12,12 +12,12 @@ This is done so files that will never be writable can be separated from files that are writable but currently locked :param filename: file to check - :raises OSError: as if the file was opened for writing + :raises OSError: as if the file was opened for writing. """ - try: - file_stat = os.stat(filename) # use stat to do exists + can write to check without race condition + try: # use stat to do exists + can write to check without race condition + file_stat = os.stat(filename) # noqa: PTH116 except OSError: - return None # swallow does not exist or other errors + return # swallow does not exist or other errors if file_stat.st_mtime != 0: # if os.stat returns but modification is zero that's an invalid os.stat - ignore it if not (file_stat.st_mode & stat.S_IWUSR): @@ -27,7 +27,7 @@ if sys.platform == "win32": # pragma: win32 cover # On Windows, this is PermissionError raise PermissionError(EACCES, "Permission denied", filename) - else: # pragma: win32 no cover + else: # pragma: win32 no cover # noqa: RET506 # On linux / macOS, this is IsADirectoryError raise IsADirectoryError(EISDIR, "Is a directory", filename) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/src/filelock/_windows.py new/filelock-3.12.1/src/filelock/_windows.py --- old/filelock-3.12.0/src/filelock/_windows.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/src/filelock/_windows.py 2020-02-02 01:00:00.000000000 +0100 @@ -2,7 +2,9 @@ import os import sys +from contextlib import suppress from errno import EACCES +from pathlib import Path from typing import cast from ._api import BaseFileLock @@ -42,11 +44,8 @@ msvcrt.locking(fd, msvcrt.LK_UNLCK, 1) os.close(fd) - try: - os.remove(self.lock_file) - # Probably another instance of the application hat acquired the file lock. - except OSError: - pass + with suppress(OSError): # Probably another instance of the application hat acquired the file lock. + Path(self.lock_file).unlink() else: # pragma: win32 no cover diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/src/filelock/version.py new/filelock-3.12.1/src/filelock/version.py --- old/filelock-3.12.0/src/filelock/version.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/src/filelock/version.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,4 +1,4 @@ # file generated by setuptools_scm # don't change, don't track in version control -__version__ = version = '3.12.0' -__version_tuple__ = version_tuple = (3, 12, 0) +__version__ = version = '3.12.1' +__version_tuple__ = version_tuple = (3, 12, 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/tests/test_error.py new/filelock-3.12.1/tests/test_error.py --- old/filelock-3.12.0/tests/test_error.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/tests/test_error.py 2020-02-02 01:00:00.000000000 +0100 @@ -22,7 +22,7 @@ def test_timeout_pickle() -> None: timeout = Timeout("/path/to/lock") - timeout_loaded = pickle.loads(pickle.dumps(timeout)) + timeout_loaded = pickle.loads(pickle.dumps(timeout)) # noqa: S301 assert timeout.__class__ == timeout_loaded.__class__ assert str(timeout) == str(timeout_loaded) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/filelock-3.12.0/tests/test_filelock.py new/filelock-3.12.1/tests/test_filelock.py --- old/filelock-3.12.0/tests/test_filelock.py 2020-02-02 01:00:00.000000000 +0100 +++ new/filelock-3.12.1/tests/test_filelock.py 2020-02-02 01:00:00.000000000 +0100 @@ -12,21 +12,14 @@ from pathlib import Path, PurePath from stat import S_IWGRP, S_IWOTH, S_IWUSR, filemode from types import TracebackType -from typing import Callable, Iterator, Tuple, Type, Union +from typing import TYPE_CHECKING, Callable, Iterator, Tuple, Type, Union from uuid import uuid4 import pytest -from _pytest.logging import LogCaptureFixture -from pytest_mock import MockerFixture +from filelock import BaseFileLock, FileLock, SoftFileLock, Timeout, UnixFileLock, WindowsFileLock -from filelock import ( - BaseFileLock, - FileLock, - SoftFileLock, - Timeout, - UnixFileLock, - WindowsFileLock, -) +if TYPE_CHECKING: + from pytest_mock import MockerFixture @pytest.mark.parametrize( @@ -44,7 +37,7 @@ lock_type: type[BaseFileLock], path_type: type[str] | type[Path], tmp_path: Path, - caplog: LogCaptureFixture, + caplog: pytest.LogCaptureFixture, ) -> None: caplog.set_level(logging.DEBUG) @@ -84,7 +77,7 @@ @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) @pytest.mark.skipif(sys.platform == "win32", reason="Windows does not have read only folders") @pytest.mark.skipif( - sys.platform != "win32" and os.geteuid() == 0, # noqa: SC200 + sys.platform != "win32" and os.geteuid() == 0, reason="Cannot make a read only file (that the current user: root can't read)", ) def test_ro_folder(lock_type: type[BaseFileLock], tmp_path_ro: Path) -> None: @@ -103,7 +96,7 @@ @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) @pytest.mark.skipif( - sys.platform != "win32" and os.geteuid() == 0, # noqa: SC200 + sys.platform != "win32" and os.geteuid() == 0, reason="Cannot make a read only file (that the current user: root can't read)", ) def test_ro_file(lock_type: type[BaseFileLock], tmp_file_ro: Path) -> None: @@ -122,11 +115,16 @@ pytest.param(FileNotFoundError, "No such file or directory:", "a/b", id="non_existent_directory"), pytest.param(FileNotFoundError, "No such file or directory:", "", id="blank_filename"), pytest.param(ValueError, "embedded null (byte|character)", "\0", id="null_byte"), - pytest.param( - PermissionError if sys.platform == "win32" else IsADirectoryError, - "Permission denied:" if sys.platform == "win32" else "Is a directory", - ".", - id="current_directory", + # Should be PermissionError on Windows + pytest.param(PermissionError, "Permission denied:", ".", id="current_directory") + if sys.platform == "win32" + else ( + # Should be IsADirectoryError on MacOS and Linux + pytest.param(IsADirectoryError, "Is a directory", ".", id="current_directory") + if sys.platform in ["darwin", "linux"] + else + # Should be some type of OSError at least on other operating systems + pytest.param(OSError, None, ".", id="current_directory") ), ] + [pytest.param(OSError, "Invalid argument", i, id=f"invalid_{i}", marks=WindowsOnly) for i in '<>:"|?*\a'] @@ -219,13 +217,12 @@ def run(self) -> None: try: super().run() - except Exception: # pragma: no cover + except Exception: # noqa: BLE001 # pragma: no cover self.ex = sys.exc_info() # pragma: no cover def join(self, timeout: float | None = None) -> None: super().join(timeout=timeout) if self.ex is not None: - print(f"fail from thread {self.name}") # pragma: no cover raise RuntimeError from self.ex[1] # pragma: no cover @@ -371,7 +368,7 @@ with lock as lock_1: assert lock is lock_1 assert lock.is_locked - raise ValueError + raise ValueError # noqa: TRY301 except ValueError: assert not lock.is_locked @@ -386,7 +383,7 @@ with lock.acquire() as lock_1: assert lock is lock_1 assert lock.is_locked - raise ValueError + raise ValueError # noqa: TRY301 except ValueError: assert not lock.is_locked @@ -465,7 +462,7 @@ lock.acquire() assert lock.is_locked - mode = filemode(os.stat(lock_path).st_mode) + mode = filemode(lock_path.stat().st_mode) assert mode == "-rw-rw-rw-" finally: os.umask(initial_umask) @@ -484,7 +481,7 @@ lock.acquire() assert lock.is_locked - mode = filemode(os.stat(lock_path).st_mode) + mode = filemode(lock_path.stat().st_mode) if sys.platform == "win32": assert mode == "-rw-rw-rw-" else: @@ -540,15 +537,14 @@ with pytest.raises(NotImplementedError): lock.acquire() with pytest.raises(NotImplementedError): - lock._release() + lock._release() # noqa: SLF001 @pytest.mark.skipif(sys.platform == "win32", reason="flock not run on windows") def test_flock_not_implemented_unix(tmp_path: Path, mocker: MockerFixture) -> None: mocker.patch("fcntl.flock", side_effect=OSError(ENOSYS, "mock error")) - with pytest.raises(NotImplementedError): - with FileLock(tmp_path / "a.lock"): - pass + with pytest.raises(NotImplementedError), FileLock(tmp_path / "a.lock"): + pass def test_soft_errors(tmp_path: Path, mocker: MockerFixture) -> None: