summaryrefslogtreecommitdiffstats
path: root/pre_commit/file_lock.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-04-04 18:42:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-04-04 18:42:30 +0000
commit9d68e4e3da4ce68e28506d926c7de9fd6ffbf6a3 (patch)
treea6d016823a24941dd795d30ba84409db12aa41cb /pre_commit/file_lock.py
parentReleasing debian version 2.17.0-1. (diff)
downloadpre-commit-9d68e4e3da4ce68e28506d926c7de9fd6ffbf6a3.tar.xz
pre-commit-9d68e4e3da4ce68e28506d926c7de9fd6ffbf6a3.zip
Merging upstream version 2.18.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/file_lock.py')
-rw-r--r--pre_commit/file_lock.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/pre_commit/file_lock.py b/pre_commit/file_lock.py
index 55a8eb2..f67a586 100644
--- a/pre_commit/file_lock.py
+++ b/pre_commit/file_lock.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import contextlib
import errno
import sys
@@ -20,13 +22,11 @@ if sys.platform == 'win32': # pragma: no cover (windows)
blocked_cb: Callable[[], None],
) -> Generator[None, None, None]:
try:
- # TODO: https://github.com/python/typeshed/pull/3607
msvcrt.locking(fileno, msvcrt.LK_NBLCK, _region)
except OSError:
blocked_cb()
while True:
try:
- # TODO: https://github.com/python/typeshed/pull/3607
msvcrt.locking(fileno, msvcrt.LK_LOCK, _region)
except OSError as e:
# Locking violation. Returned when the _LK_LOCK or _LK_RLCK
@@ -45,7 +45,6 @@ if sys.platform == 'win32': # pragma: no cover (windows)
# The documentation however states:
# "Regions should be locked only briefly and should be unlocked
# before closing a file or exiting the program."
- # TODO: https://github.com/python/typeshed/pull/3607
msvcrt.locking(fileno, msvcrt.LK_UNLCK, _region)
else: # pragma: win32 no cover
import fcntl