From 9dcd46b244bfda645829d249474bca09e4f3826a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Sun, 4 Dec 2022 23:37:32 -0800 Subject: [PATCH] Fix mypy fails understanding FileLock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernát Gábor --- .github/workflows/check.yml | 2 ++ .pre-commit-config.yaml | 8 ++++---- docs/changelog.rst | 18 ++++++++++++++++++ pyproject.toml | 2 +- setup.cfg | 4 ++-- src/filelock/__init__.py | 6 +++++- tox.ini | 8 ++++---- 7 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 47561a2..982135e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -27,6 +27,8 @@ jobs: - ubuntu-22.04 - windows-2022 - macos-12 + exclude: + - { os: windows-2022, py: "pypy3.9" } steps: - name: Setup python for tox diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1203cd0..8755d62 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-ast - id: check-builtin-literals @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v3.2.2 + rev: v3.3.0 hooks: - id: pyupgrade args: [ "--py36-plus" ] @@ -44,7 +44,7 @@ repos: - id: tox-ini-fmt args: [ "-p", "fix_lint" ] - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: @@ -53,5 +53,5 @@ repos: - flake8-pytest-style==1.6 - flake8-spellcheck==0.28 - flake8-unused-arguments==0.0.12 - - flake8-noqa==1.2.9 + - flake8-noqa==1.3 - pep8-naming==0.13.2 diff --git a/docs/changelog.rst b/docs/changelog.rst index 80d92c7..7ee9ffc 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,24 @@ Changelog ========= +v3.8.1 (2022-12-04) +------------------- +- Fix mypy does not accept ``filelock.FileLock`` as a valid type + +v3.8.0 (2022-12-04) +------------------- +- Bump project dependencies +- Add timeout unit to docstrings +- Support 3.11 + +v3.7.1 (2022-05-31) +------------------- +- Make the readme documentation point to the index page + +v3.7.0 (2022-05-13) +------------------- +- Add ability to return immediately when a lock cannot be obtained + v3.6.0 (2022-02-17) ------------------- - Fix pylint warning "Abstract class :class:`WindowsFileLock ` with abstract methods instantiated" diff --git a/pyproject.toml b/pyproject.toml index 6a9a654..4075294 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "setuptools>=65.5", + "setuptools>=65.6.3", "setuptools_scm>=7.0.5", ] build-backend = 'setuptools.build_meta' diff --git a/setup.cfg b/setup.cfg index f7fe98c..d6f28d9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,9 +38,9 @@ where = src docs = furo>=2022.9.29 sphinx>=5.3 - sphinx-autodoc-typehints>=1.19.4 + sphinx-autodoc-typehints>=1.19.5 testing = - covdefaults>=2.2 + covdefaults>=2.2.2 coverage>=6.5 pytest>=7.2 pytest-cov>=4 diff --git a/src/filelock/__init__.py b/src/filelock/__init__.py index afcdb70..36fe7e4 100644 --- a/src/filelock/__init__.py +++ b/src/filelock/__init__.py @@ -9,6 +9,7 @@ import sys import warnings +from typing import TYPE_CHECKING from ._api import AcquireReturnProxy, BaseFileLock from ._error import Timeout @@ -33,7 +34,10 @@ #: 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 +if TYPE_CHECKING: + FileLock = SoftFileLock +else: + FileLock = _FileLock __all__ = [ diff --git a/tox.ini b/tox.ini index 9309507..e2b63c6 100644 --- a/tox.ini +++ b/tox.ini @@ -50,7 +50,7 @@ description = run type check on code base setenv = {tty:MYPY_FORCE_COLOR = 1} deps = - mypy==0.982 + mypy==0.991 commands = mypy --strict src/filelock mypy --strict tests @@ -63,9 +63,9 @@ setenv = COVERAGE_FILE = {toxworkdir}/.coverage skip_install = true deps = - covdefaults>=2.2 + covdefaults>=2.2.2 coverage>=6.5 - diff-cover>=7.0.1 + diff-cover>=7.2 extras = parallel_show_output = true commands = @@ -95,7 +95,7 @@ description = check that the long description is valid (need for PyPI) skip_install = true deps = build[virtualenv]>=0.9 - twine>=4.0.1 + twine>=4.0.2 extras = commands = pyproject-build -o {envtmpdir} --wheel --sdist .