1212from pathlib import Path , PurePath
1313from stat import S_IWGRP , S_IWOTH , S_IWUSR , filemode
1414from types import TracebackType
15- from typing import TYPE_CHECKING , Any , Callable , Iterator , Tuple , Type , Union
15+ from typing import TYPE_CHECKING , Any , Callable , Union
1616from uuid import uuid4
1717from weakref import WeakValueDictionary
1818
2121from filelock import BaseFileLock , FileLock , SoftFileLock , Timeout , UnixFileLock , WindowsFileLock
2222
2323if TYPE_CHECKING :
24+ from collections .abc import Iterator
25+
2426 from pytest_mock import MockerFixture
2527
2628
@@ -218,7 +220,7 @@ def test_nested_contruct(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
218220 assert not lock_1 .is_locked
219221
220222
221- _ExcInfoType = Union [Tuple [ Type [BaseException ], BaseException , TracebackType ], Tuple [None , None , None ]]
223+ _ExcInfoType = Union [tuple [ type [BaseException ], BaseException , TracebackType ], tuple [None , None , None ]]
222224
223225
224226class ExThread (threading .Thread ):
@@ -304,7 +306,7 @@ def test_timeout(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
304306 assert not lock_2 .is_locked
305307
306308 # try to acquire lock 2
307- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ):
309+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ):
308310 lock_2 .acquire (timeout = 0.1 )
309311 assert not lock_2 .is_locked
310312 assert lock_1 .is_locked
@@ -333,44 +335,44 @@ def test_non_blocking(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
333335 assert not lock_5 .is_locked
334336
335337 # try to acquire lock 2
336- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ):
338+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ):
337339 lock_2 .acquire (blocking = False )
338340 assert not lock_2 .is_locked
339341 assert lock_1 .is_locked
340342
341343 # try to acquire pre-parametrized `blocking=False` lock 3 with `acquire`
342- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ):
344+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ):
343345 lock_3 .acquire ()
344346 assert not lock_3 .is_locked
345347 assert lock_1 .is_locked
346348
347349 # try to acquire pre-parametrized `blocking=False` lock 3 with context manager
348- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ), lock_3 :
350+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ), lock_3 :
349351 pass
350352 assert not lock_3 .is_locked
351353 assert lock_1 .is_locked
352354
353355 # try to acquire pre-parametrized `timeout=0` lock 4 with `acquire`
354- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ):
356+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ):
355357 lock_4 .acquire ()
356358 assert not lock_4 .is_locked
357359 assert lock_1 .is_locked
358360
359361 # try to acquire pre-parametrized `timeout=0` lock 4 with context manager
360- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ), lock_4 :
362+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ), lock_4 :
361363 pass
362364 assert not lock_4 .is_locked
363365 assert lock_1 .is_locked
364366
365367 # blocking precedence over timeout
366368 # try to acquire pre-parametrized `timeout=-1,blocking=False` lock 5 with `acquire`
367- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ):
369+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ):
368370 lock_5 .acquire ()
369371 assert not lock_5 .is_locked
370372 assert lock_1 .is_locked
371373
372374 # try to acquire pre-parametrized `timeout=-1,blocking=False` lock 5 with context manager
373- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ), lock_5 :
375+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ), lock_5 :
374376 pass
375377 assert not lock_5 .is_locked
376378 assert lock_1 .is_locked
@@ -397,15 +399,15 @@ def test_default_timeout(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
397399 assert not lock_2 .is_locked
398400
399401 # try to acquire lock 2
400- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ):
402+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ):
401403 lock_2 .acquire ()
402404 assert not lock_2 .is_locked
403405 assert lock_1 .is_locked
404406
405407 lock_2 .timeout = 0
406408 assert lock_2 .timeout == 0
407409
408- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ):
410+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ):
409411 lock_2 .acquire ()
410412 assert not lock_2 .is_locked
411413 assert lock_1 .is_locked
@@ -459,7 +461,7 @@ def test_del(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
459461 assert not lock_2 .is_locked
460462
461463 # try to acquire lock 2
462- with pytest .raises (Timeout , match = "The file lock '.*' could not be acquired." ):
464+ with pytest .raises (Timeout , match = r "The file lock '.*' could not be acquired." ):
463465 lock_2 .acquire (timeout = 0.1 )
464466
465467 # delete lock 1 and try to acquire lock 2 again
0 commit comments