Projects
Mega:23.09
python-filelock
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 3
View file
_service:tar_scm:python-filelock.spec
Changed
@@ -1,10 +1,10 @@ Name: python-filelock -Version: 3.12.2 +Version: 3.13.1 Release: 1 Summary: A platform independent file lock License: Unlicense URL: https://github.com/benediktschmitt/py-filelock -Source0: https://files.pythonhosted.org/packages/00/0b/c506e9e44e4c4b6c89fcecda23dc115bf8e7ff7eb127e0cb9c114cbc9a15/filelock-3.12.2.tar.gz +Source0: https://files.pythonhosted.org/packages/70/70/41905c80dcfe71b22fb06827b8eae65781783d4a14194bce79d16a013263/filelock-3.13.1.tar.gz BuildArch: noarch @@ -41,7 +41,7 @@ %pyproject_build %install -%pyproject_install filelock==%{version} +%pyproject_install %check export PYTHONPATH=%{buildroot}%{python3_sitelib}/ @@ -62,6 +62,12 @@ %doc README.md %changelog +* Wed Dec 06 2023 jiangxinyu <jiangxinyu@kylinos.cn> - 3.13.1-1 +- Update package to version 3.13.1 + +* Thu Oct 26 2023 jiangxinyu <jiangxinyu@kylinos.cn> - 3.12.4-1 +- Update package to version 3.12.4 + * Wed Jun 21 2023 chendexi <chendexi@kylinos.cn> - 3.12.2-1 - Update package to version 3.12.2
View file
_service
Changed
@@ -2,7 +2,7 @@ <service name="tar_scm"> <param name="url">git@gitee.com:src-openeuler/python-filelock.git</param> <param name="scm">git</param> - <param name="revision">openEuler-23.09</param> + <param name="revision">master</param> <param name="exclude">*</param> <param name="extract">*</param> </service>
View file
_service:tar_scm:filelock-3.12.2.tar.gz/PKG-INFO -> _service:tar_scm:filelock-3.13.1.tar.gz/PKG-INFO
Changed
@@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: filelock -Version: 3.12.2 +Version: 3.13.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 @@ -16,7 +16,6 @@ Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python 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 @@ -25,22 +24,24 @@ Classifier: Topic :: Internet Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: System -Requires-Python: >=3.7 +Requires-Python: >=3.8 Provides-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>=7.0.1; extra == 'docs' +Requires-Dist: furo>=2023.9.10; extra == 'docs' +Requires-Dist: sphinx-autodoc-typehints!=1.23.4,>=1.24; extra == 'docs' +Requires-Dist: sphinx>=7.2.6; extra == 'docs' Provides-Extra: testing Requires-Dist: covdefaults>=2.3; extra == 'testing' -Requires-Dist: coverage>=7.2.7; extra == 'testing' -Requires-Dist: diff-cover>=7.5; extra == 'testing' +Requires-Dist: coverage>=7.3.2; extra == 'testing' +Requires-Dist: diff-cover>=8; 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' +Requires-Dist: pytest-mock>=3.12; extra == 'testing' +Requires-Dist: pytest-timeout>=2.2; extra == 'testing' +Requires-Dist: pytest>=7.4.3; extra == 'testing' +Provides-Extra: typing +Requires-Dist: typing-extensions>=4.8; python_version < '3.11' and extra == 'typing' Description-Content-Type: text/markdown -# py-filelock +# filelock !PyPI(https://img.shields.io/pypi/v/filelock)(https://pypi.org/project/filelock/) !Supported Python @@ -49,7 +50,7 @@ status(https://readthedocs.org/projects/py-filelock/badge/?version=latest)(https://py-filelock.readthedocs.io/en/latest/?badge=latest) !Code style: black(https://img.shields.io/badge/code%20style-black-000000.svg)(https://github.com/psf/black) -!Downloads(https://pepy.tech/badge/filelock/month)(https://pepy.tech/project/filelock) +!Downloads(https://static.pepy.tech/badge/filelock/month)(https://pepy.tech/project/filelock) !check(https://github.com/tox-dev/py-filelock/actions/workflows/check.yml/badge.svg)(https://github.com/tox-dev/py-filelock/actions/workflows/check.yml) For more information checkout the official documentation(https://py-filelock.readthedocs.io/en/latest/index.html).
View file
_service:tar_scm:filelock-3.12.2.tar.gz/README.md -> _service:tar_scm:filelock-3.13.1.tar.gz/README.md
Changed
@@ -1,4 +1,4 @@ -# py-filelock +# filelock !PyPI(https://img.shields.io/pypi/v/filelock)(https://pypi.org/project/filelock/) !Supported Python @@ -7,7 +7,7 @@ status(https://readthedocs.org/projects/py-filelock/badge/?version=latest)(https://py-filelock.readthedocs.io/en/latest/?badge=latest) !Code style: black(https://img.shields.io/badge/code%20style-black-000000.svg)(https://github.com/psf/black) -!Downloads(https://pepy.tech/badge/filelock/month)(https://pepy.tech/project/filelock) +!Downloads(https://static.pepy.tech/badge/filelock/month)(https://pepy.tech/project/filelock) !check(https://github.com/tox-dev/py-filelock/actions/workflows/check.yml/badge.svg)(https://github.com/tox-dev/py-filelock/actions/workflows/check.yml) For more information checkout the official documentation(https://py-filelock.readthedocs.io/en/latest/index.html).
View file
_service:tar_scm:filelock-3.12.2.tar.gz/pyproject.toml -> _service:tar_scm:filelock-3.13.1.tar.gz/pyproject.toml
Changed
@@ -2,7 +2,7 @@ build-backend = "hatchling.build" requires = "hatch-vcs>=0.3", - "hatchling>=1.17.1", + "hatchling>=1.18", project @@ -18,7 +18,7 @@ license = "Unlicense" maintainers = { name = "Bernát Gábor", email = "gaborjbernat@gmail.com" } -requires-python = ">=3.7" +requires-python = ">=3.8" classifiers = "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", @@ -26,7 +26,6 @@ "Operating System :: OS Independent", "Programming Language :: Python", "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", @@ -40,18 +39,21 @@ "version", optional-dependencies.docs = - "furo>=2023.5.20", - "sphinx>=7.0.1", - "sphinx-autodoc-typehints!=1.23.4,>=1.23", + "furo>=2023.9.10", + "sphinx>=7.2.6", + "sphinx-autodoc-typehints!=1.23.4,>=1.24", optional-dependencies.testing = "covdefaults>=2.3", - "coverage>=7.2.7", - "diff-cover>=7.5", - "pytest>=7.3.1", + "coverage>=7.3.2", + "diff-cover>=8", + "pytest>=7.4.3", "pytest-cov>=4.1", - "pytest-mock>=3.10", - "pytest-timeout>=2.1", + "pytest-mock>=3.12", + "pytest-timeout>=2.2", + +optional-dependencies.typing = + 'typing-extensions>=4.8; python_version < "3.11"', urls.Documentation = "https://py-filelock.readthedocs.io" urls.Homepage = "https://github.com/tox-dev/py-filelock" @@ -60,32 +62,17 @@ tool.hatch build.hooks.vcs.version-file = "src/filelock/version.py" -build.targets.sdist.include = "/src", "/tests" +build.targets.sdist.include = "/src", "/tests", "/tox.ini" version.source = "vcs" tool.black line-length = 120 -tool.coverage -html.show_contexts = true -html.skip_covered = false -paths.source = "src", ".tox/*/lib/*/site-packages", ".tox\\*\\Lib\\site-packages", "**/src", "**\\src" -paths.other = ".", "*/py-filelock", "*\\py-filelock" -report.fail_under = 76 -run.parallel = true -run.plugins = "covdefaults" - -tool.mypy -python_version = "3.11" -show_error_codes = true -strict = true -overrides = { module = "appdirs.*", "jnius.*", ignore_missing_imports = true } - tool.ruff select = "ALL" line-length = 120 -target-version = "py37" -isort = {known-first-party = "platformdirs", "tests", required-imports = "from __future__ import annotations"} +target-version = "py38" +isort = {known-first-party = "filelock", required-imports = "from __future__ import annotations"} ignore = "ANN101", # Missing type annotation for `self` in method "D301", # Use `r"""` if any backslashes in a docstring @@ -104,3 +91,18 @@ "S603", # `subprocess` call: check for execution of untrusted input "PLR2004", # Magic value used in comparison, consider replacing with a constant variable + +tool.coverage +html.show_contexts = true +html.skip_covered = false +paths.source = "src", ".tox/*/lib/*/site-packages", ".tox\\*\\Lib\\site-packages", "**/src", "**\\src" +paths.other = ".", "*/filelock", "*\\filelock" +report.fail_under = 76 +run.parallel = true +run.plugins = "covdefaults" + +tool.mypy +python_version = "3.11" +show_error_codes = true +strict = true +overrides = { module = "appdirs.*", "jnius.*", ignore_missing_imports = true }
View file
_service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/__init__.py -> _service:tar_scm:filelock-3.13.1.tar.gz/src/filelock/__init__.py
Changed
@@ -24,15 +24,15 @@ if sys.platform == "win32": # pragma: win32 cover _FileLock: typeBaseFileLock = WindowsFileLock -else: # pragma: win32 no cover - if has_fcntl: # noqa: PLR5501 +else: # pragma: win32 no cover # noqa: PLR5501 + if has_fcntl: _FileLock: typeBaseFileLock = UnixFileLock else: _FileLock = SoftFileLock if warnings is not None: warnings.warn("only soft file lock is available", stacklevel=2) -if TYPE_CHECKING: # noqa: SIM108 +if TYPE_CHECKING: FileLock = SoftFileLock else: #: Alias for the lock, which should be used for the current platform.
View file
_service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_api.py -> _service:tar_scm:filelock-3.13.1.tar.gz/src/filelock/_api.py
Changed
@@ -8,13 +8,21 @@ from abc import ABC, abstractmethod from dataclasses import dataclass from threading import local -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any, ClassVar +from weakref import WeakValueDictionary from ._error import Timeout if TYPE_CHECKING: + import sys from types import TracebackType + if sys.version_info >= (3, 11): # pragma: no cover (py311+) + from typing import Self + else: # pragma: no cover (<py311) + from typing_extensions import Self + + _LOGGER = logging.getLogger("filelock") @@ -69,25 +77,54 @@ class BaseFileLock(ABC, contextlib.ContextDecorator): """Abstract base class for a file lock object.""" - def __init__( + _instances: ClassVarWeakValueDictionarystr, BaseFileLock = WeakValueDictionary() + + def __new__( # noqa: PLR0913 + cls, + lock_file: str | os.PathLikestr, + timeout: float = -1, # noqa: ARG003 + mode: int = 0o644, # noqa: ARG003 + thread_local: bool = True, # noqa: ARG003, FBT001, FBT002 + *, + is_singleton: bool = False, + **kwargs: dictstr, Any, # capture remaining kwargs for subclasses # noqa: ARG003 + ) -> Self: + """Create a new lock object or if specified return the singleton instance for the lock file.""" + if not is_singleton: + return super().__new__(cls) + + instance = cls._instances.get(str(lock_file)) + if not instance: + instance = super().__new__(cls) + cls._instancesstr(lock_file) = instance + + return instance # type: ignorereturn-value # https://github.com/python/mypy/issues/15322 + + def __init__( # noqa: PLR0913 self, - lock_file: str | os.PathLikeAny, + lock_file: str | os.PathLikestr, timeout: float = -1, mode: int = 0o644, thread_local: bool = True, # noqa: FBT001, FBT002 + *, + is_singleton: bool = False, ) -> None: """ Create a new lock object. :param lock_file: path to the file - :param timeout: default timeout when acquiring the lock, in seconds. It will be used as fallback value in - the acquire method, if no timeout value (``None``) is given. If you want to disable the timeout, set it - to a negative value. A timeout of 0 means, that there is exactly one attempt to acquire the file lock. - :param mode: file permissions for the lockfile. - :param thread_local: Whether this object's internal context should be thread local or not. - If this is set to ``False`` then the lock will be reentrant across threads. + :param timeout: default timeout when acquiring the lock, in seconds. It will be used as fallback value in \ + the acquire method, if no timeout value (``None``) is given. If you want to disable the timeout, set it \ + to a negative value. A timeout of 0 means, that there is exactly one attempt to acquire the file lock. + :param mode: file permissions for the lockfile + :param thread_local: Whether this object's internal context should be thread local or not. If this is set to \ + ``False`` then the lock will be reentrant across threads. + :param is_singleton: If this is set to ``True`` then only one instance of this class will be created \ + per lock file. This is useful if you want to use the lock object for reentrant locking without needing \ + to pass the same object around. """ self._is_thread_local = thread_local + self._is_singleton = is_singleton # Create the context. Note that external code should not work with the context directly and should instead use # properties of this class. @@ -103,6 +140,11 @@ return self._is_thread_local @property + def is_singleton(self) -> bool: + """:return: a flag indicating if this lock is singleton or not""" + return self._is_singleton + + @property def lock_file(self) -> str: """:return: path to the lock file""" return self._context.lock_file @@ -246,7 +288,7 @@ self._context.lock_counter = 0 _LOGGER.debug("Lock %s released on %s", lock_id, lock_filename) - def __enter__(self) -> BaseFileLock: + def __enter__(self) -> Self: """ Acquire the lock.
View file
_service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_soft.py -> _service:tar_scm:filelock-3.13.1.tar.gz/src/filelock/_soft.py
Changed
@@ -7,7 +7,7 @@ from pathlib import Path from ._api import BaseFileLock -from ._util import raise_on_not_writable_file +from ._util import ensure_directory_exists, raise_on_not_writable_file class SoftFileLock(BaseFileLock): @@ -15,6 +15,7 @@ def _acquire(self) -> None: raise_on_not_writable_file(self.lock_file) + ensure_directory_exists(self.lock_file) # first check for exists and read-only mode as the open will mask this case as EEXIST flags = ( os.O_WRONLY # open for writing only
View file
_service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_unix.py -> _service:tar_scm:filelock-3.13.1.tar.gz/src/filelock/_unix.py
Changed
@@ -7,6 +7,7 @@ from typing import cast from ._api import BaseFileLock +from ._util import ensure_directory_exists #: a flag to indicate if the fcntl API is available has_fcntl = False @@ -33,6 +34,7 @@ """Uses the :func:`fcntl.flock` to hard lock the lock file on unix systems.""" def _acquire(self) -> None: + ensure_directory_exists(self.lock_file) open_flags = os.O_RDWR | os.O_CREAT | os.O_TRUNC fd = os.open(self.lock_file, open_flags, self._context.mode) with suppress(PermissionError): # This locked is not owned by this UID
View file
_service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_util.py -> _service:tar_scm:filelock-3.13.1.tar.gz/src/filelock/_util.py
Changed
@@ -4,6 +4,7 @@ import stat import sys from errno import EACCES, EISDIR +from pathlib import Path def raise_on_not_writable_file(filename: str) -> None: @@ -32,6 +33,15 @@ raise IsADirectoryError(EISDIR, "Is a directory", filename) +def ensure_directory_exists(filename: Path | str) -> None: + """ + Ensure the directory containing the file exists (create it if necessary) + :param filename: file. + """ + Path(filename).parent.mkdir(parents=True, exist_ok=True) + + __all__ = "raise_on_not_writable_file", + "ensure_directory_exists",
View file
_service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/_windows.py -> _service:tar_scm:filelock-3.13.1.tar.gz/src/filelock/_windows.py
Changed
@@ -8,7 +8,7 @@ from typing import cast from ._api import BaseFileLock -from ._util import raise_on_not_writable_file +from ._util import ensure_directory_exists, raise_on_not_writable_file if sys.platform == "win32": # pragma: win32 cover import msvcrt @@ -18,6 +18,7 @@ def _acquire(self) -> None: raise_on_not_writable_file(self.lock_file) + ensure_directory_exists(self.lock_file) flags = ( os.O_RDWR # open for read and write | os.O_CREAT # create file if not exists
View file
_service:tar_scm:filelock-3.12.2.tar.gz/src/filelock/version.py -> _service:tar_scm:filelock-3.13.1.tar.gz/src/filelock/version.py
Changed
@@ -1,4 +1,16 @@ # file generated by setuptools_scm # don't change, don't track in version control -__version__ = version = '3.12.2' -__version_tuple__ = version_tuple = (3, 12, 2) +TYPE_CHECKING = False +if TYPE_CHECKING: + from typing import Tuple, Union + VERSION_TUPLE = TupleUnionint, str, ... +else: + VERSION_TUPLE = object + +version: str +__version__: str +__version_tuple__: VERSION_TUPLE +version_tuple: VERSION_TUPLE + +__version__ = version = '3.13.1' +__version_tuple__ = version_tuple = (3, 13, 1)
View file
_service:tar_scm:filelock-3.12.2.tar.gz/tests/test_filelock.py -> _service:tar_scm:filelock-3.13.1.tar.gz/tests/test_filelock.py
Changed
@@ -12,37 +12,31 @@ from pathlib import Path, PurePath from stat import S_IWGRP, S_IWOTH, S_IWUSR, filemode from types import TracebackType -from typing import TYPE_CHECKING, Callable, Iterator, Tuple, Type, Union +from typing import TYPE_CHECKING, Any, Callable, Iterator, Tuple, Type, Union from uuid import uuid4 import pytest + from filelock import BaseFileLock, FileLock, SoftFileLock, Timeout, UnixFileLock, WindowsFileLock if TYPE_CHECKING: from pytest_mock import MockerFixture -@pytest.mark.parametrize( - ("lock_type", "path_type"), - - (FileLock, str), - (FileLock, PurePath), - (FileLock, Path), - (SoftFileLock, str), - (SoftFileLock, PurePath), - (SoftFileLock, Path), - , -) +@pytest.mark.parametrize("lock_type", FileLock, SoftFileLock) +@pytest.mark.parametrize("path_type", str, PurePath, Path) +@pytest.mark.parametrize("filename", "a", "new/b", "new2/new3/c") def test_simple( lock_type: typeBaseFileLock, - path_type: typestr | typePath, + path_type: typestr | Path, + filename: str, tmp_path: Path, caplog: pytest.LogCaptureFixture, ) -> None: caplog.set_level(logging.DEBUG) # test lock creation by passing a `str` - lock_path = tmp_path / "a" + lock_path = tmp_path / filename lock = lock_type(path_type(lock_path)) with lock as locked: assert lock.is_locked @@ -112,7 +106,6 @@ @pytest.mark.parametrize( ("expected_error", "match", "bad_lock_file"), - 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"), # Should be PermissionError on Windows @@ -568,11 +561,8 @@ lock_file, txt_file = tmp_path / "test.txt.lock", tmp_path / "test.txt" lock = lock_type(lock_file) - results = with ThreadPoolExecutor() as executor: - for _ in range(100): - results.append(executor.submit(mess_with_file, lock)) - + results = executor.submit(mess_with_file, lock) for _ in range(100) assert all(r.result() is None for r in results) @@ -584,10 +574,8 @@ lock_file, txt_file = tmp_path / "test.txt.lock", tmp_path / "test.txt" lock = lock_type(lock_file) - results = with ThreadPoolExecutor() as executor: - for _ in range(100): - results.append(executor.submit(mess_with_file)) + results = executor.submit(mess_with_file) for _ in range(100) assert all(r.result() is None for r in results) @@ -602,10 +590,8 @@ _check_file_read_write(txt_file) lock_file, txt_file = tmp_path / "test.txt.lock", tmp_path / "test.txt" - results = with ThreadPoolExecutor() as executor: - for _ in range(100): - results.append(executor.submit(mess_with_file)) + results = executor.submit(mess_with_file) for _ in range(100) assert all(r.result() is None for r in results) @@ -625,3 +611,78 @@ assert lock.lock_counter == 2 lock.release(force=True) + + +def test_subclass_compatibility(tmp_path: Path) -> None: + class MyFileLock(FileLock): + def __init__( # noqa: PLR0913 Too many arguments to function call (6 > 5) + self, + lock_file: str | os.PathLikestr, + timeout: float = -1, + mode: int = 0o644, + thread_local: bool = True, + my_param: int = 0, + **kwargs: dictstr, Any, + ) -> None: + pass + + lock_path = tmp_path / "a" + MyFileLock(str(lock_path), my_param=1) + + class MySoftFileLock(SoftFileLock): + def __init__( # noqa: PLR0913 Too many arguments to function call (6 > 5) + self, + lock_file: str | os.PathLikestr, + timeout: float = -1, + mode: int = 0o644, + thread_local: bool = True, + my_param: int = 0, + **kwargs: dictstr, Any, + ) -> None: + pass + + MySoftFileLock(str(lock_path), my_param=1) + + +@pytest.mark.parametrize("lock_type", FileLock, SoftFileLock) +def test_singleton_and_non_singleton_locks_are_distinct(lock_type: typeBaseFileLock, tmp_path: Path) -> None: + lock_path = tmp_path / "a" + lock_1 = lock_type(str(lock_path), is_singleton=False) + assert lock_1.is_singleton is False + + lock_2 = lock_type(str(lock_path), is_singleton=True) + assert lock_2.is_singleton is True + assert lock_2 is not lock_1 + + +@pytest.mark.parametrize("lock_type", FileLock, SoftFileLock) +def test_singleton_locks_are_the_same(lock_type: typeBaseFileLock, tmp_path: Path) -> None: + lock_path = tmp_path / "a" + lock_1 = lock_type(str(lock_path), is_singleton=True) + + lock_2 = lock_type(str(lock_path), is_singleton=True) + assert lock_2 is lock_1 + + +@pytest.mark.parametrize("lock_type", FileLock, SoftFileLock) +def test_singleton_locks_are_distinct_per_lock_file(lock_type: typeBaseFileLock, tmp_path: Path) -> None: + lock_path_1 = tmp_path / "a" + lock_1 = lock_type(str(lock_path_1), is_singleton=True) + + lock_path_2 = tmp_path / "b" + lock_2 = lock_type(str(lock_path_2), is_singleton=True) + assert lock_1 is not lock_2 + + +@pytest.mark.skipif(hasattr(sys, "pypy_version_info"), reason="del() does not trigger GC in PyPy") +@pytest.mark.parametrize("lock_type", FileLock, SoftFileLock) +def test_singleton_locks_are_deleted_when_no_external_references_exist( + lock_type: typeBaseFileLock, + tmp_path: Path, +) -> None: + lock_path = tmp_path / "a" + lock = lock_type(str(lock_path), is_singleton=True) + + assert lock_type._instances == {str(lock_path): lock} # noqa: SLF001 + del lock + assert lock_type._instances == {} # noqa: SLF001
View file
_service:tar_scm:filelock-3.13.1.tar.gz/tox.ini
Added
@@ -0,0 +1,109 @@ +tox +requires = + tox>=4.2 +env_list = + fix + py312 + py311 + py310 + py39 + py38 + py37 + type + coverage + docs + readme +skip_missing_interpreters = true + +testenv +description = run tests with {basepython} +package = wheel +wheel_build_env = .pkg +extras = + testing +pass_env = + PYTEST_ADDOPTS +set_env = + COVERAGE_FILE = {toxworkdir}{/}.coverage.{envname} +commands = + pytest {tty:--color=yes} {posargs: \ + --junitxml {toxworkdir}{/}junit.{envname}.xml --cov {envsitepackagesdir}{/}filelock --cov {toxinidir}{/}tests \ + --cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \ + --cov-report html:{envtmpdir}{/}htmlcov --cov-report xml:{toxworkdir}{/}coverage.{envname}.xml \ + tests + diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}{/}coverage.{envname}.xml} + +testenv:fix +description = format the code base to adhere to our styles, and complain about what we cannot do automatically +base_python = python3.10 +skip_install = true +deps = + pre-commit>=3.5 +commands = + pre-commit run --all-files --show-diff-on-failure + python -c 'import pathlib; print("hint: run \{\} install to add checks as pre-commit hook".format(pathlib.Path(r"{envdir}") / "bin" / "pre-commit"))' + +testenv:type +description = run type check on code base +deps = + mypy==1.6.1 +set_env = + {tty:MYPY_FORCE_COLOR = 1} +commands = + mypy --strict src/filelock + mypy --strict tests + +testenv:coverage +description = combine coverage files and generate diff (against DIFF_AGAINST defaulting to origin/main) +skip_install = true +deps = + covdefaults>=2.3 + coveragetoml>=7.3.2 + diff-cover>=8 +extras = +parallel_show_output = true +pass_env = + DIFF_AGAINST +set_env = + COVERAGE_FILE = {toxworkdir}/.coverage +commands = + coverage combine + coverage report --skip-covered --show-missing + coverage xml -o {toxworkdir}/coverage.xml + coverage html -d {toxworkdir}/htmlcov + diff-cover --compare-branch {env:DIFF_AGAINST:origin/main} {toxworkdir}/coverage.xml +depends = + py311 + py310 + py39 + py38 + py37 + +testenv:docs +description = build documentation +extras = + docs +commands = + sphinx-build -d "{envtmpdir}{/}doctree" docs "{toxworkdir}{/}docs_out" --color -b html -W {posargs} + python -c 'print(r"documentation available under file://{toxworkdir}{/}docs_out{/}index.html")' + +testenv:readme +description = check that the long description is valid (need for PyPI) +skip_install = true +deps = + buildvirtualenv>=1.0.3 + twine>=4.0.2 +extras = +commands = + pyproject-build -o {envtmpdir} --wheel --sdist . + twine check {envtmpdir}/* + +testenv:dev +description = generate a DEV environment +package = editable +extras = + docs + testing +commands = + python -m pip list --format=columns + python -c 'import sys; print(sys.executable)'
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