Skip to content

Commit

Permalink
Drop support for python3.6
Browse files Browse the repository at this point in the history
And start testing with 3.11.

Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
  • Loading branch information
gaborbernat committed Dec 26, 2021
1 parent 6823192 commit 1654479
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 48 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/check.yml
Expand Up @@ -25,11 +25,11 @@ jobs:
matrix:
py:
- "3.10"
- "pypy-3.7-v7.3.7" # ahead to start it earlier because takes longer
- "3.9"
- "3.8"
- "3.7"
- "3.6"
- "pypy-3.7-v7.3.7"
- "3.11-dev" # as is not yet released do it at the end
os:
- ubuntu-20.04
- windows-2022
Expand All @@ -51,7 +51,10 @@ jobs:
python-version: ${{ matrix.py }}
- name: Pick environment to run
run: |
import codecs; import os; import platform; import sys
import codecs
import os
import platform
import sys
cpy = platform.python_implementation() == "CPython"
base =("{}{}{}" if cpy else "{}{}").format("py" if cpy else "pypy", *sys.version_info[0:2])
env = "TOXENV={}\n".format(base)
Expand Down Expand Up @@ -106,7 +109,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: html-report
path: htmlcov
path: .tox/htmlcov

check:
name: ${{ matrix.tox_env }} - ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -43,7 +43,7 @@ repos:
rev: v1.20.0
hooks:
- id: setup-cfg-fmt
args: [ --min-py3-version, "3.6", "--max-py-version", "3.10" ]
args: [ --min-py3-version, "3.7", "--max-py-version", "3.11" ]
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
Expand Down
6 changes: 5 additions & 1 deletion docs/changelog.rst
@@ -1,7 +1,11 @@
Changelog
=========

v3.4.1 (2021-13-16)
v3.4.2 (2021-12-16)
-------------------
- Drop support for python ``3.6``

v3.4.1 (2021-12-16)
-------------------
- Add ``stacklevel`` to deprecation warnings for argument name change

Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Expand Up @@ -16,11 +16,11 @@ classifiers =
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
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
Topic :: Internet
Topic :: Software Development :: Libraries
Topic :: System
Expand All @@ -31,7 +31,7 @@ project_urls =

[options]
packages = find:
python_requires = >=3.6
python_requires = >=3.7
package_dir =
=src
zip_safe = True
Expand Down
2 changes: 2 additions & 0 deletions setup.py
@@ -1,3 +1,5 @@
from __future__ import annotations

from setuptools import setup

setup()
9 changes: 5 additions & 4 deletions src/filelock/__init__.py
Expand Up @@ -5,9 +5,10 @@
:no-value:
"""
from __future__ import annotations

import sys
import warnings
from typing import Type

from ._api import AcquireReturnProxy, BaseFileLock
from ._error import Timeout
Expand All @@ -21,18 +22,18 @@


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:
warnings.warn("only soft file lock is available")

#: 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__ = [
Expand Down
32 changes: 17 additions & 15 deletions src/filelock/_api.py
@@ -1,11 +1,13 @@
from __future__ import annotations

import logging
import os
import time
import warnings
from abc import ABC, abstractmethod
from threading import Lock
from types import TracebackType
from typing import Any, Optional, Type, Union
from typing import Any

from ._error import Timeout

Expand All @@ -18,25 +20,25 @@
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: Optional[Type[BaseException]], # noqa: U100
exc_value: Optional[BaseException], # noqa: U100
traceback: Optional[TracebackType], # noqa: U100
exc_type: type[BaseException] | None, # noqa: U100
exc_value: BaseException | None, # noqa: U100
traceback: TracebackType | None, # noqa: U100
) -> None:
self.lock.release()


class BaseFileLock(ABC):
"""Abstract base class for a file lock object."""

def __init__(self, lock_file: Union[str, "os.PathLike[Any]"], timeout: float = -1) -> None:
def __init__(self, lock_file: str | os.PathLike[Any], timeout: float = -1) -> None:
"""
Create a new lock object.
Expand All @@ -50,7 +52,7 @@ def __init__(self, lock_file: Union[str, "os.PathLike[Any]"], timeout: float = -

# 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: Optional[int] = None
self._lock_file_fd: int | None = None

# The default timeout value.
self.timeout: float = timeout
Expand All @@ -77,7 +79,7 @@ def timeout(self) -> float:
return self._timeout

@timeout.setter
def timeout(self, value: Union[float, str]) -> None:
def timeout(self, value: float | str) -> None:
"""
Change the default timeout value.
Expand Down Expand Up @@ -109,10 +111,10 @@ def is_locked(self) -> bool:

def acquire(
self,
timeout: Optional[float] = None,
timeout: float | None = None,
poll_interval: float = 0.05,
*,
poll_intervall: Optional[float] = None,
poll_intervall: float | None = None,
) -> AcquireReturnProxy:
"""
Try to acquire the file lock.
Expand Down Expand Up @@ -202,7 +204,7 @@ def release(self, force: bool = False) -> None:
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.
Expand All @@ -213,9 +215,9 @@ def __enter__(self) -> "BaseFileLock":

def __exit__(
self,
exc_type: Optional[Type[BaseException]], # noqa: U100
exc_value: Optional[BaseException], # noqa: U100
traceback: Optional[TracebackType], # noqa: U100
exc_type: type[BaseException] | None, # noqa: U100
exc_value: BaseException | None, # noqa: U100
traceback: TracebackType | None, # noqa: U100
) -> None:
"""
Release the lock.
Expand Down
3 changes: 3 additions & 0 deletions src/filelock/_error.py
@@ -1,3 +1,6 @@
from __future__ import annotations


class Timeout(TimeoutError):
"""Raised when the lock could not be acquired in *timeout* seconds."""

Expand Down
2 changes: 2 additions & 0 deletions src/filelock/_soft.py
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import sys
from errno import EACCES, EEXIST, ENOENT
Expand Down
2 changes: 2 additions & 0 deletions src/filelock/_unix.py
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import sys
from abc import ABC
Expand Down
2 changes: 2 additions & 0 deletions src/filelock/_util.py
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import stat

Expand Down
2 changes: 2 additions & 0 deletions src/filelock/_windows.py
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import sys
from abc import ABC
Expand Down

0 comments on commit 1654479

Please sign in to comment.