Projects
openEuler:Mainline
python-filelock
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 5
View file
_service:tar_scm:python-filelock.spec
Changed
@@ -1,10 +1,10 @@ Name: python-filelock -Version: 3.12.0 +Version: 3.12.2 Release: 1 Summary: A platform independent file lock License: Unlicense URL: https://github.com/benediktschmitt/py-filelock -Source0: https://files.pythonhosted.org/packages/24/85/cf4df939cc0a037ebfe18353005e775916faec24dcdbc7a2f6539ad9d943/filelock-3.12.0.tar.gz +Source0: https://files.pythonhosted.org/packages/00/0b/c506e9e44e4c4b6c89fcecda23dc115bf8e7ff7eb127e0cb9c114cbc9a15/filelock-3.12.2.tar.gz BuildArch: noarch @@ -62,6 +62,9 @@ %doc README.md %changelog +* Wed Jun 21 2023 chendexi <chendexi@kylinos.cn> - 3.12.2-1 +- Update package to version 3.12.2 + * Thu Apr 27 2023 xu_ping <707078654@qq.com> - 3.12.0-1 - Upgrade to 3.12.0
View file
_service:tar_scm:filelock-3.12.0.tar.gz/PKG-INFO -> _service:tar_scm:filelock-3.12.2.tar.gz/PKG-INFO
Changed
@@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: filelock -Version: 3.12.0 +Version: 3.12.2 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'
View file
_service:tar_scm:filelock-3.12.0.tar.gz/pyproject.toml -> _service:tar_scm:filelock-3.12.2.tar.gz/pyproject.toml
Changed
@@ -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 +
View file
_service:tar_scm:filelock-3.12.0.tar.gz/src/filelock/__init__.py -> _service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/__init__.py
Changed
@@ -25,14 +25,14 @@ if sys.platform == "win32": # pragma: win32 cover _FileLock: typeBaseFileLock = WindowsFileLock else: # pragma: win32 no cover - if has_fcntl: + if has_fcntl: # noqa: PLR5501 _FileLock: typeBaseFileLock = UnixFileLock else: _FileLock = SoftFileLock if warnings is not None: warnings.warn("only soft file lock is available", stacklevel=2) -if TYPE_CHECKING: +if TYPE_CHECKING: # noqa: SIM108 FileLock = SoftFileLock else: #: Alias for the lock, which should be used for the current platform.
View file
_service:tar_scm:filelock-3.12.0.tar.gz/src/filelock/_api.py -> _service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_api.py
Changed
@@ -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: typeBaseException | None, # noqa: U100 - exc_value: BaseException | None, # noqa: U100 - traceback: TracebackType | None, # noqa: U100 + exc_type: typeBaseException | 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.PathLikeAny, 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: typeBaseException | None, # noqa: U100 - exc_value: BaseException | None, # noqa: U100 - traceback: TracebackType | None, # noqa: U100 + exc_type: typeBaseException | None, + exc_value: BaseException | None, + traceback: TracebackType | None, ) -> None: """ Release the lock.
View file
_service:tar_scm:filelock-3.12.0.tar.gz/src/filelock/_error.py -> _service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_error.py
Changed
@@ -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:
View file
_service:tar_scm:filelock-3.12.0.tar.gz/src/filelock/_soft.py -> _service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_soft.py
Changed
@@ -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__ =
View file
_service:tar_scm:filelock-3.12.0.tar.gz/src/filelock/_unix.py -> _service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_unix.py
Changed
@@ -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
View file
_service:tar_scm:filelock-3.12.0.tar.gz/src/filelock/_util.py -> _service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_util.py
Changed
@@ -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)
View file
_service:tar_scm:filelock-3.12.0.tar.gz/src/filelock/_windows.py -> _service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_windows.py
Changed
@@ -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
View file
_service:tar_scm:filelock-3.12.0.tar.gz/src/filelock/version.py -> _service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/version.py
Changed
@@ -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.2' +__version_tuple__ = version_tuple = (3, 12, 2)
View file
_service:tar_scm:filelock-3.12.0.tar.gz/tests/test_error.py -> _service:tar_scm:filelock-3.12.2.tar.gz/tests/test_error.py
Changed
@@ -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)
View file
_service:tar_scm:filelock-3.12.0.tar.gz/tests/test_filelock.py -> _service:tar_scm:filelock-3.12.2.tar.gz/tests/test_filelock.py
Changed
@@ -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: typeBaseFileLock, path_type: typestr | typePath, 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: typeBaseFileLock, 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: typeBaseFileLock, 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.ex1 # 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:
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2