|
12 | 12 | from pathlib import Path, PurePath |
13 | 13 | from stat import S_IWGRP, S_IWOTH, S_IWUSR, filemode |
14 | 14 | from types import TracebackType |
15 | | -from typing import TYPE_CHECKING, Callable, Iterator, Tuple, Type, Union |
| 15 | +from typing import TYPE_CHECKING, Any, Callable, Iterator, Tuple, Type, Union |
16 | 16 | from uuid import uuid4 |
17 | 17 |
|
18 | 18 | import pytest |
@@ -613,6 +613,37 @@ def test_lock_can_be_non_thread_local( |
613 | 613 | lock.release(force=True) |
614 | 614 |
|
615 | 615 |
|
| 616 | +def test_subclass_compatibility(tmp_path: Path) -> None: |
| 617 | + class MyFileLock(FileLock): |
| 618 | + def __init__( # noqa: PLR0913 Too many arguments to function call (6 > 5) |
| 619 | + self, |
| 620 | + lock_file: str | os.PathLike[str], |
| 621 | + timeout: float = -1, |
| 622 | + mode: int = 0o644, |
| 623 | + thread_local: bool = True, |
| 624 | + my_param: int = 0, |
| 625 | + **kwargs: dict[str, Any], |
| 626 | + ) -> None: |
| 627 | + pass |
| 628 | + |
| 629 | + lock_path = tmp_path / "a" |
| 630 | + MyFileLock(str(lock_path), my_param=1) |
| 631 | + |
| 632 | + class MySoftFileLock(SoftFileLock): |
| 633 | + def __init__( # noqa: PLR0913 Too many arguments to function call (6 > 5) |
| 634 | + self, |
| 635 | + lock_file: str | os.PathLike[str], |
| 636 | + timeout: float = -1, |
| 637 | + mode: int = 0o644, |
| 638 | + thread_local: bool = True, |
| 639 | + my_param: int = 0, |
| 640 | + **kwargs: dict[str, Any], |
| 641 | + ) -> None: |
| 642 | + pass |
| 643 | + |
| 644 | + MySoftFileLock(str(lock_path), my_param=1) |
| 645 | + |
| 646 | + |
616 | 647 | @pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock]) |
617 | 648 | def test_singleton_and_non_singleton_locks_are_distinct(lock_type: type[BaseFileLock], tmp_path: Path) -> None: |
618 | 649 | lock_path = tmp_path / "a" |
|
0 commit comments