Skip to content

Commit

Permalink
Fix mypy fails understanding FileLock
Browse files Browse the repository at this point in the history
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Dec 5, 2022
1 parent efa8911 commit 9dcd46b
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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" ]
Expand Down Expand Up @@ -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:
Expand All @@ -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
18 changes: 18 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -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 <filelock.WindowsFileLock>` with abstract methods instantiated"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"setuptools>=65.5",
"setuptools>=65.6.3",
"setuptools_scm>=7.0.5",
]
build-backend = 'setuptools.build_meta'
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/filelock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import sys
import warnings
from typing import TYPE_CHECKING

from ._api import AcquireReturnProxy, BaseFileLock
from ._error import Timeout
Expand All @@ -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__ = [
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand Down Expand Up @@ -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 .
Expand Down

0 comments on commit 9dcd46b

Please sign in to comment.