Skip to content

Commit 579ccc3

Browse files
authored
Fix mypy fails understanding FileLock (#177)
1 parent b693fe1 commit 579ccc3

File tree

7 files changed

+36
-12
lines changed

7 files changed

+36
-12
lines changed

.github/workflows/check.yml

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
- ubuntu-22.04
2828
- windows-2022
2929
- macos-12
30+
exclude:
31+
- { os: windows-2022, py: "pypy3.9" }
3032

3133
steps:
3234
- name: Setup python for tox

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.3.0
3+
rev: v4.4.0
44
hooks:
55
- id: check-ast
66
- id: check-builtin-literals
@@ -12,7 +12,7 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: trailing-whitespace
1414
- repo: https://github.com/asottile/pyupgrade
15-
rev: v3.2.2
15+
rev: v3.3.0
1616
hooks:
1717
- id: pyupgrade
1818
args: [ "--py36-plus" ]
@@ -44,7 +44,7 @@ repos:
4444
- id: tox-ini-fmt
4545
args: [ "-p", "fix_lint" ]
4646
- repo: https://github.com/PyCQA/flake8
47-
rev: 5.0.4
47+
rev: 6.0.0
4848
hooks:
4949
- id: flake8
5050
additional_dependencies:
@@ -53,5 +53,5 @@ repos:
5353
- flake8-pytest-style==1.6
5454
- flake8-spellcheck==0.28
5555
- flake8-unused-arguments==0.0.12
56-
- flake8-noqa==1.2.9
56+
- flake8-noqa==1.3
5757
- pep8-naming==0.13.2

docs/changelog.rst

+18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
Changelog
22
=========
33

4+
v3.8.1 (2022-12-04)
5+
-------------------
6+
- Fix mypy does not accept ``filelock.FileLock`` as a valid type
7+
8+
v3.8.0 (2022-12-04)
9+
-------------------
10+
- Bump project dependencies
11+
- Add timeout unit to docstrings
12+
- Support 3.11
13+
14+
v3.7.1 (2022-05-31)
15+
-------------------
16+
- Make the readme documentation point to the index page
17+
18+
v3.7.0 (2022-05-13)
19+
-------------------
20+
- Add ability to return immediately when a lock cannot be obtained
21+
422
v3.6.0 (2022-02-17)
523
-------------------
624
- Fix pylint warning "Abstract class :class:`WindowsFileLock <filelock.WindowsFileLock>` with abstract methods instantiated"

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
22
requires = [
3-
"setuptools>=65.5",
3+
"setuptools>=65.6.3",
44
"setuptools_scm>=7.0.5",
55
]
66
build-backend = 'setuptools.build_meta'

setup.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ where = src
3838
docs =
3939
furo>=2022.9.29
4040
sphinx>=5.3
41-
sphinx-autodoc-typehints>=1.19.4
41+
sphinx-autodoc-typehints>=1.19.5
4242
testing =
43-
covdefaults>=2.2
43+
covdefaults>=2.2.2
4444
coverage>=6.5
4545
pytest>=7.2
4646
pytest-cov>=4

src/filelock/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import sys
1111
import warnings
12+
from typing import TYPE_CHECKING
1213

1314
from ._api import AcquireReturnProxy, BaseFileLock
1415
from ._error import Timeout
@@ -33,7 +34,10 @@
3334

3435
#: Alias for the lock, which should be used for the current platform. On Windows, this is an alias for
3536
# :class:`WindowsFileLock`, on Unix for :class:`UnixFileLock` and otherwise for :class:`SoftFileLock`.
36-
FileLock: type[BaseFileLock] = _FileLock
37+
if TYPE_CHECKING:
38+
FileLock = SoftFileLock
39+
else:
40+
FileLock = _FileLock
3741

3842

3943
__all__ = [

tox.ini

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ description = run type check on code base
5050
setenv =
5151
{tty:MYPY_FORCE_COLOR = 1}
5252
deps =
53-
mypy==0.982
53+
mypy==0.991
5454
commands =
5555
mypy --strict src/filelock
5656
mypy --strict tests
@@ -63,9 +63,9 @@ setenv =
6363
COVERAGE_FILE = {toxworkdir}/.coverage
6464
skip_install = true
6565
deps =
66-
covdefaults>=2.2
66+
covdefaults>=2.2.2
6767
coverage>=6.5
68-
diff-cover>=7.0.1
68+
diff-cover>=7.2
6969
extras =
7070
parallel_show_output = true
7171
commands =
@@ -95,7 +95,7 @@ description = check that the long description is valid (need for PyPI)
9595
skip_install = true
9696
deps =
9797
build[virtualenv]>=0.9
98-
twine>=4.0.1
98+
twine>=4.0.2
9999
extras =
100100
commands =
101101
pyproject-build -o {envtmpdir} --wheel --sdist .

0 commit comments

Comments
 (0)