Skip to content

Commit 8838dcd

Browse files
authored
Merge branch 'main' into fix-nested-cm
2 parents b439608 + 87453f3 commit 8838dcd

File tree

6 files changed

+571
-29
lines changed

6 files changed

+571
-29
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repos:
55
- id: end-of-file-fixer
66
- id: trailing-whitespace
77
- repo: https://github.com/codespell-project/codespell
8-
rev: v2.2.6
8+
rev: v2.3.0
99
hooks:
1010
- id: codespell
1111
args: ["--write-changes"]
@@ -15,12 +15,12 @@ repos:
1515
- id: tox-ini-fmt
1616
args: ["-p", "fix"]
1717
- repo: https://github.com/tox-dev/pyproject-fmt
18-
rev: "1.8.0"
18+
rev: "2.1.3"
1919
hooks:
2020
- id: pyproject-fmt
2121
additional_dependencies: ["tox>=4.12.1"]
2222
- repo: https://github.com/astral-sh/ruff-pre-commit
23-
rev: "v0.4.1"
23+
rev: "v0.4.8"
2424
hooks:
2525
- id: ruff-format
2626
- id: ruff

pyproject.toml

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ keywords = [
1717
"user",
1818
]
1919
license = "Unlicense"
20-
maintainers = [{ name = "Bernát Gábor", email = "[email protected]" }]
20+
maintainers = [
21+
{ name = "Bernát Gábor", email = "[email protected]" },
22+
]
2123
requires-python = ">=3.8"
2224
classifiers = [
2325
"Development Status :: 5 - Production/Stable",
@@ -48,12 +50,13 @@ optional-dependencies.testing = [
4850
"coverage>=7.3.2",
4951
"diff-cover>=8.0.1",
5052
"pytest>=7.4.3",
53+
"pytest-asyncio>=0.21",
5154
"pytest-cov>=4.1",
5255
"pytest-mock>=3.12",
5356
"pytest-timeout>=2.2",
5457
]
5558
optional-dependencies.typing = [
56-
'typing-extensions>=4.8; python_version < "3.11"',
59+
"typing-extensions>=4.8; python_version<'3.11'",
5760
]
5861
urls.Documentation = "https://py-filelock.readthedocs.io"
5962
urls.Homepage = "https://github.com/tox-dev/py-filelock"
@@ -62,39 +65,48 @@ urls.Tracker = "https://github.com/tox-dev/py-filelock/issues"
6265

6366
[tool.hatch]
6467
build.hooks.vcs.version-file = "src/filelock/version.py"
65-
build.targets.sdist.include = ["/src", "/tests", "/tox.ini"]
68+
build.targets.sdist.include = [
69+
"/src",
70+
"/tests",
71+
"/tox.ini",
72+
]
6673
version.source = "vcs"
6774

6875
[tool.ruff]
69-
line-length = 120
7076
target-version = "py38"
71-
lint.isort = { known-first-party = ["filelock"], required-imports = ["from __future__ import annotations"] }
72-
lint.select = ["ALL"]
77+
line-length = 120
78+
format.preview = true
79+
format.docstring-code-line-length = 100
80+
format.docstring-code-format = true
81+
lint.select = [
82+
"ALL",
83+
]
7384
lint.ignore = [
7485
"ANN101", # Missing type annotation for `self` in method
75-
"D301", # Use `r"""` if any backslashes in a docstring
76-
"D205", # 1 blank line required between summary line and description
77-
"D401", # First line of docstring should be in imperative mood
86+
"COM812", # Conflict with formatter
87+
"CPY", # No copyright statements
7888
"D203", # `one-blank-line-before-class` (D203) and `no-blank-line-before-class` (D211) are incompatible
89+
"D205", # 1 blank line required between summary line and description
7990
"D212", # `multi-line-summary-first-line` (D212) and `multi-line-summary-second-line` (D213) are incompatible
80-
"S104", # Possible binding to all interface
81-
"COM812", # Conflict with formatter
91+
"D301", # Use `r"""` if any backslashes in a docstring
92+
"D401", # First line of docstring should be in imperative mood
8293
"ISC001", # Conflict with formatter
83-
"CPY", # No copyright statements
94+
"S104", # Possible binding to all interface
8495
]
85-
lint.preview = true
86-
format.preview = true
87-
format.docstring-code-format = true
88-
format.docstring-code-line-length = 100
89-
[tool.ruff.lint.per-file-ignores]
90-
"tests/**/*.py" = [
91-
"S101", # asserts allowed in tests...
96+
lint.per-file-ignores."tests/**/*.py" = [
97+
"D", # don"t care about documentation in tests
9298
"FBT", # don"t care about booleans as positional arguments in tests
9399
"INP001", # no implicit namespace
94-
"D", # don"t care about documentation in tests
95-
"S603", # `subprocess` call: check for execution of untrusted input
96100
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
101+
"S101", # asserts allowed in tests...
102+
"S603", # `subprocess` call: check for execution of untrusted input
97103
]
104+
lint.isort = { known-first-party = [
105+
"filelock",
106+
], required-imports = [
107+
"from __future__ import annotations",
108+
] }
109+
lint.preview = true
98110

99111
[tool.codespell]
100112
builtin = "clear,usage,en-GB_to_en-US"
@@ -105,14 +117,31 @@ ignore-words-list = "master"
105117
[tool.coverage]
106118
html.show_contexts = true
107119
html.skip_covered = false
108-
paths.source = ["src", ".tox/*/lib/*/site-packages", ".tox\\*\\Lib\\site-packages", "**/src", "**\\src"]
109-
paths.other = [".", "*/filelock", "*\\filelock"]
120+
paths.source = [
121+
"src",
122+
".tox/*/lib/*/site-packages",
123+
".tox\\*\\Lib\\site-packages",
124+
"**/src",
125+
"**\\src",
126+
]
127+
paths.other = [
128+
".",
129+
"*/filelock",
130+
"*\\filelock",
131+
]
110132
report.fail_under = 76
111133
run.parallel = true
112-
run.plugins = ["covdefaults"]
134+
run.plugins = [
135+
"covdefaults",
136+
]
113137

114138
[tool.mypy]
115139
python_version = "3.11"
116140
show_error_codes = true
117141
strict = true
118-
overrides = [{ module = ["appdirs.*", "jnius.*"], ignore_missing_imports = true }]
142+
overrides = [
143+
{ module = [
144+
"appdirs.*",
145+
"jnius.*",
146+
], ignore_missing_imports = true },
147+
]

src/filelock/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
from ._soft import SoftFileLock
1818
from ._unix import UnixFileLock, has_fcntl
1919
from ._windows import WindowsFileLock
20+
from .asyncio import (
21+
AsyncAcquireReturnProxy,
22+
AsyncSoftFileLock,
23+
AsyncUnixFileLock,
24+
AsyncWindowsFileLock,
25+
BaseAsyncFileLock,
26+
)
2027
from .version import version
2128

2229
#: version of the project as a string
@@ -25,23 +32,34 @@
2532

2633
if sys.platform == "win32": # pragma: win32 cover
2734
_FileLock: type[BaseFileLock] = WindowsFileLock
35+
_AsyncFileLock: type[BaseAsyncFileLock] = AsyncWindowsFileLock
2836
else: # pragma: win32 no cover # noqa: PLR5501
2937
if has_fcntl:
3038
_FileLock: type[BaseFileLock] = UnixFileLock
39+
_AsyncFileLock: type[BaseAsyncFileLock] = AsyncUnixFileLock
3140
else:
3241
_FileLock = SoftFileLock
42+
_AsyncFileLock = AsyncSoftFileLock
3343
if warnings is not None:
3444
warnings.warn("only soft file lock is available", stacklevel=2)
3545

3646
if TYPE_CHECKING:
3747
FileLock = SoftFileLock
48+
AsyncFileLock = AsyncSoftFileLock
3849
else:
3950
#: Alias for the lock, which should be used for the current platform.
4051
FileLock = _FileLock
52+
AsyncFileLock = _AsyncFileLock
4153

4254

4355
__all__ = [
4456
"AcquireReturnProxy",
57+
"AsyncAcquireReturnProxy",
58+
"AsyncFileLock",
59+
"AsyncSoftFileLock",
60+
"AsyncUnixFileLock",
61+
"AsyncWindowsFileLock",
62+
"BaseAsyncFileLock",
4563
"BaseFileLock",
4664
"FileLock",
4765
"SoftFileLock",

src/filelock/_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __new__( # noqa: PLR0913
9191
*,
9292
blocking: bool = True,
9393
is_singleton: bool = False,
94-
**kwargs: dict[str, Any], # capture remaining kwargs for subclasses # noqa: ARG003
94+
**kwargs: Any, # capture remaining kwargs for subclasses # noqa: ARG003, ANN401
9595
) -> Self:
9696
"""Create a new lock object or if specified return the singleton instance for the lock file."""
9797
if not is_singleton:

0 commit comments

Comments
 (0)