Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
M17N:l10n.opensuse.org:Backports-2022.11
python-filelock
0001-Revert-Drop-support-for-python3.6-125.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Revert-Drop-support-for-python3.6-125.patch of Package python-filelock
From c61df24afea0aec25c3f4bca9446b6832a720045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta?= <meggy.calabkova@gmail.com> Date: Fri, 2 Dec 2022 10:52:53 +0100 Subject: [PATCH] Revert "Drop support for python3.6 (#125)" This reverts commit b5e956c3a8e4bc80430209b3136dfb2a6f953d83. --- .github/workflows/check.yml | 2 +- setup.cfg | 2 +- setup.py | 2 -- src/filelock/__init__.py | 9 ++++----- src/filelock/_api.py | 33 ++++++++++++++++----------------- src/filelock/_error.py | 3 --- src/filelock/_soft.py | 2 -- src/filelock/_unix.py | 2 -- src/filelock/_util.py | 2 -- src/filelock/_windows.py | 2 -- tests/test_filelock.py | 36 +++++++++++++++++------------------- tox.ini | 6 +++--- 12 files changed, 42 insertions(+), 59 deletions(-) Index: filelock-3.7.1/.github/workflows/check.yml =================================================================== --- filelock-3.7.1.orig/.github/workflows/check.yml +++ filelock-3.7.1/.github/workflows/check.yml @@ -108,7 +108,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: html-report - path: .tox/htmlcov + path: htmlcov check: name: ${{ matrix.tox_env }} - ${{ matrix.os }} Index: filelock-3.7.1/setup.cfg =================================================================== --- filelock-3.7.1.orig/setup.cfg +++ filelock-3.7.1/setup.cfg @@ -30,7 +30,7 @@ project_urls = [options] packages = find: -python_requires = >=3.7 +python_requires = >=3.6 package_dir = =src zip_safe = True Index: filelock-3.7.1/setup.py =================================================================== --- filelock-3.7.1.orig/setup.py +++ filelock-3.7.1/setup.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from setuptools import setup setup() Index: filelock-3.7.1/src/filelock/__init__.py =================================================================== --- filelock-3.7.1.orig/src/filelock/__init__.py +++ filelock-3.7.1/src/filelock/__init__.py @@ -5,10 +5,9 @@ A platform independent file lock that su :no-value: """ -from __future__ import annotations - import sys import warnings +from typing import Type from ._api import AcquireReturnProxy, BaseFileLock from ._error import Timeout @@ -22,10 +21,10 @@ __version__: str = version if sys.platform == "win32": # pragma: win32 cover - _FileLock: type[BaseFileLock] = WindowsFileLock + _FileLock: Type[BaseFileLock] = WindowsFileLock else: # pragma: win32 no cover if has_fcntl: - _FileLock: type[BaseFileLock] = UnixFileLock + _FileLock: Type[BaseFileLock] = UnixFileLock else: _FileLock = SoftFileLock if warnings is not None: @@ -33,7 +32,7 @@ else: # pragma: win32 no cover #: Alias for the lock, which should be used for the current platform. On Windows, this is an alias for # :class:`WindowsFileLock`, on Unix for :class:`UnixFileLock` and otherwise for :class:`SoftFileLock`. -FileLock: type[BaseFileLock] = _FileLock +FileLock: Type[BaseFileLock] = _FileLock __all__ = [ Index: filelock-3.7.1/src/filelock/_api.py =================================================================== --- filelock-3.7.1.orig/src/filelock/_api.py +++ filelock-3.7.1/src/filelock/_api.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import contextlib import logging import os @@ -8,7 +6,7 @@ import warnings from abc import ABC, abstractmethod from threading import Lock from types import TracebackType -from typing import Any +from typing import Any, Optional, Type, Union from ._error import Timeout @@ -21,17 +19,17 @@ _LOGGER = logging.getLogger("filelock") class AcquireReturnProxy: """A context aware object that will release the lock file when exiting.""" - def __init__(self, lock: BaseFileLock) -> None: + def __init__(self, lock: "BaseFileLock") -> None: self.lock = lock - def __enter__(self) -> BaseFileLock: + def __enter__(self) -> "BaseFileLock": return self.lock def __exit__( self, - exc_type: type[BaseException] | None, # noqa: U100 - exc_value: BaseException | None, # noqa: U100 - traceback: TracebackType | None, # noqa: U100 + exc_type: Optional[Type[BaseException]], # noqa: U100 + exc_value: Optional[BaseException], # noqa: U100 + traceback: Optional[TracebackType], # noqa: U100 ) -> None: self.lock.release() @@ -39,7 +37,7 @@ class AcquireReturnProxy: class BaseFileLock(ABC, contextlib.ContextDecorator): """Abstract base class for a file lock object.""" - def __init__(self, lock_file: str | os.PathLike[Any], timeout: float = -1) -> None: + def __init__(self, lock_file: Union[str, "os.PathLike[Any]"], timeout: float = -1) -> None: """ Create a new lock object. @@ -53,7 +51,7 @@ class BaseFileLock(ABC, contextlib.Conte # The file descriptor for the *_lock_file* as it is returned by the os.open() function. # This file lock is only NOT None, if the object currently holds the lock. - self._lock_file_fd: int | None = None + self._lock_file_fd: Optional[int] = None # The default timeout value. self.timeout: float = timeout @@ -80,7 +78,7 @@ class BaseFileLock(ABC, contextlib.Conte return self._timeout @timeout.setter - def timeout(self, value: float | str) -> None: + def timeout(self, value: Union[float, str]) -> None: """ Change the default timeout value. @@ -112,10 +110,10 @@ class BaseFileLock(ABC, contextlib.Conte def acquire( self, - timeout: float | None = None, + timeout: Optional[float] = None, poll_interval: float = 0.05, *, - poll_intervall: float | None = None, + poll_intervall: Optional[float] = None, blocking: bool = True, ) -> AcquireReturnProxy: """ @@ -211,7 +209,7 @@ class BaseFileLock(ABC, contextlib.Conte self._lock_counter = 0 _LOGGER.debug("Lock %s released on %s", lock_id, lock_filename) - def __enter__(self) -> BaseFileLock: + def __enter__(self) -> "BaseFileLock": """ Acquire the lock. @@ -222,9 +220,9 @@ class BaseFileLock(ABC, contextlib.Conte def __exit__( self, - exc_type: type[BaseException] | None, # noqa: U100 - exc_value: BaseException | None, # noqa: U100 - traceback: TracebackType | None, # noqa: U100 + exc_type: Optional[Type[BaseException]], # noqa: U100 + exc_value: Optional[BaseException], # noqa: U100 + traceback: Optional[TracebackType], # noqa: U100 ) -> None: """ Release the lock. Index: filelock-3.7.1/src/filelock/_error.py =================================================================== --- filelock-3.7.1.orig/src/filelock/_error.py +++ filelock-3.7.1/src/filelock/_error.py @@ -1,6 +1,3 @@ -from __future__ import annotations - - class Timeout(TimeoutError): """Raised when the lock could not be acquired in *timeout* seconds.""" Index: filelock-3.7.1/src/filelock/_soft.py =================================================================== --- filelock-3.7.1.orig/src/filelock/_soft.py +++ filelock-3.7.1/src/filelock/_soft.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import sys from errno import EACCES, EEXIST, ENOENT Index: filelock-3.7.1/src/filelock/_unix.py =================================================================== --- filelock-3.7.1.orig/src/filelock/_unix.py +++ filelock-3.7.1/src/filelock/_unix.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import sys from typing import cast Index: filelock-3.7.1/src/filelock/_util.py =================================================================== --- filelock-3.7.1.orig/src/filelock/_util.py +++ filelock-3.7.1/src/filelock/_util.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import stat Index: filelock-3.7.1/src/filelock/_windows.py =================================================================== --- filelock-3.7.1.orig/src/filelock/_windows.py +++ filelock-3.7.1/src/filelock/_windows.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import os import sys from errno import ENOENT Index: filelock-3.7.1/tests/test_filelock.py =================================================================== --- filelock-3.7.1.orig/tests/test_filelock.py +++ filelock-3.7.1/tests/test_filelock.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import inspect import logging import sys @@ -9,7 +7,7 @@ from inspect import getframeinfo, stack from pathlib import Path, PurePath from stat import S_IWGRP, S_IWOTH, S_IWUSR from types import TracebackType -from typing import Callable, Iterator, Tuple, Type, Union +from typing import Callable, Iterator, Optional, Tuple, Type, Union import pytest from _pytest.logging import LogCaptureFixture @@ -29,7 +27,7 @@ from filelock import BaseFileLock, FileL ], ) def test_simple( - lock_type: type[BaseFileLock], path_type: type[str] | type[Path], tmp_path: Path, caplog: LogCaptureFixture + lock_type: Type[BaseFileLock], path_type: Union[Type[str], Type[Path]], tmp_path: Path, caplog: LogCaptureFixture ) -> None: caplog.set_level(logging.DEBUG) @@ -68,7 +66,7 @@ def tmp_path_ro(tmp_path: Path) -> Itera @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) @pytest.mark.skipif(sys.platform == "win32", reason="Windows does not have read only folders") -def test_ro_folder(lock_type: type[BaseFileLock], tmp_path_ro: Path) -> None: +def test_ro_folder(lock_type: Type[BaseFileLock], tmp_path_ro: Path) -> None: lock = lock_type(str(tmp_path_ro / "a")) with pytest.raises(PermissionError, match="Permission denied"): lock.acquire() @@ -83,14 +81,14 @@ def tmp_file_ro(tmp_path: Path) -> Itera @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_ro_file(lock_type: type[BaseFileLock], tmp_file_ro: Path) -> None: +def test_ro_file(lock_type: Type[BaseFileLock], tmp_file_ro: Path) -> None: lock = lock_type(str(tmp_file_ro)) with pytest.raises(PermissionError, match="Permission denied"): lock.acquire() @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_missing_directory(lock_type: type[BaseFileLock], tmp_path_ro: Path) -> None: +def test_missing_directory(lock_type: Type[BaseFileLock], tmp_path_ro: Path) -> None: lock_path = tmp_path_ro / "a" / "b" lock = lock_type(str(lock_path)) @@ -99,7 +97,7 @@ def test_missing_directory(lock_type: ty @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_nested_context_manager(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_nested_context_manager(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # lock is not released before the most outer with statement that locked the lock, is left lock_path = tmp_path / "a" lock = lock_type(str(lock_path)) @@ -122,7 +120,7 @@ def test_nested_context_manager(lock_typ @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_nested_acquire(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_nested_acquire(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # lock is not released before the most outer with statement that locked the lock, is left lock_path = tmp_path / "a" lock = lock_type(str(lock_path)) @@ -145,7 +143,7 @@ def test_nested_acquire(lock_type: type[ @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_nested_forced_release(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_nested_forced_release(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # acquires the lock using a with-statement and releases the lock before leaving the with-statement lock_path = tmp_path / "a" lock = lock_type(str(lock_path)) @@ -167,7 +165,7 @@ _ExcInfoType = Union[Tuple[Type[BaseExce class ExThread(threading.Thread): def __init__(self, target: Callable[[], None], name: str) -> None: super().__init__(target=target, name=name) - self.ex: _ExcInfoType | None = None + self.ex: Optional[_ExcInfoType] = None def run(self) -> None: try: @@ -175,7 +173,7 @@ class ExThread(threading.Thread): except Exception: # pragma: no cover self.ex = sys.exc_info() # pragma: no cover - def join(self, timeout: float | None = None) -> None: + def join(self, timeout: Optional[float] = None) -> None: super().join(timeout=timeout) if self.ex is not None: print(f"fail from thread {self.name}") # pragma: no cover @@ -183,7 +181,7 @@ class ExThread(threading.Thread): @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_threaded_shared_lock_obj(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_threaded_shared_lock_obj(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # Runs 100 threads, which need the filelock. The lock must be acquired if at least one thread required it and # released, as soon as all threads stopped. lock_path = tmp_path / "a" @@ -205,7 +203,7 @@ def test_threaded_shared_lock_obj(lock_t @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) @pytest.mark.skipif(hasattr(sys, "pypy_version_info") and sys.platform == "win32", reason="deadlocks randomly") -def test_threaded_lock_different_lock_obj(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_threaded_lock_different_lock_obj(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # Runs multiple threads, which acquire the same lock file with a different FileLock object. When thread group 1 # acquired the lock, thread group 2 must not hold their lock. @@ -237,7 +235,7 @@ def test_threaded_lock_different_lock_ob @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_timeout(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_timeout(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # raises Timeout error when the lock cannot be acquired lock_path = tmp_path / "a" lock_1, lock_2 = lock_type(str(lock_path)), lock_type(str(lock_path)) @@ -260,7 +258,7 @@ def test_timeout(lock_type: type[BaseFil @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_non_blocking(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_non_blocking(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # raises Timeout error when the lock cannot be acquired lock_path = tmp_path / "a" lock_1, lock_2 = lock_type(str(lock_path)), lock_type(str(lock_path)) @@ -283,7 +281,7 @@ def test_non_blocking(lock_type: type[Ba @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_default_timeout(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_default_timeout(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # test if the default timeout parameter works lock_path = tmp_path / "a" lock_1, lock_2 = lock_type(str(lock_path)), lock_type(str(lock_path), timeout=0.1) @@ -315,7 +313,7 @@ def test_default_timeout(lock_type: type @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_context_release_on_exc(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_context_release_on_exc(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # lock is released when an exception is thrown in a with-statement lock_path = tmp_path / "a" lock = lock_type(str(lock_path)) @@ -330,7 +328,7 @@ def test_context_release_on_exc(lock_typ @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_acquire_release_on_exc(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_acquire_release_on_exc(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # lock is released when an exception is thrown in a acquire statement lock_path = tmp_path / "a" lock = lock_type(str(lock_path)) @@ -346,7 +344,7 @@ def test_acquire_release_on_exc(lock_typ @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_del(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_del(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: # lock is released when the object is deleted lock_path = tmp_path / "a" lock_1, lock_2 = lock_type(str(lock_path)), lock_type(str(lock_path)) @@ -380,7 +378,7 @@ def test_cleanup_soft_lock(tmp_path: Pat @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_poll_intervall_deprecated(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_poll_intervall_deprecated(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: lock_path = tmp_path / "a" lock = lock_type(str(lock_path)) @@ -395,7 +393,7 @@ def test_poll_intervall_deprecated(lock_ @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) -def test_context_decorator(lock_type: type[BaseFileLock], tmp_path: Path) -> None: +def test_context_decorator(lock_type: Type[BaseFileLock], tmp_path: Path) -> None: lock_path = tmp_path / "a" lock = lock_type(str(lock_path))
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor