diff --git a/src/filelock/read_write/_api.py b/src/filelock/read_write/_api.py index 90205c5..9032a6c 100644 --- a/src/filelock/read_write/_api.py +++ b/src/filelock/read_write/_api.py @@ -6,11 +6,11 @@ from pathlib import Path from typing import TYPE_CHECKING -from .._api import BaseFileLock - if TYPE_CHECKING: import os + from filelock._api import BaseFileLock + if TYPE_CHECKING: import sys from types import TracebackType diff --git a/src/filelock/read_write/_wrapper.py b/src/filelock/read_write/_wrapper.py index a17852e..f1bd3f8 100644 --- a/src/filelock/read_write/_wrapper.py +++ b/src/filelock/read_write/_wrapper.py @@ -1,7 +1,9 @@ -from abc import ABCMeta +from __future__ import annotations +from abc import ABC -class BaseReadWriteFileLockWrapper(metaclass=ABCMeta): + +class BaseReadWriteFileLockWrapper(ABC): _read_write_file_lock_cls: Type[BaseReadWriteFileLock] def __init__( # noqa: PLR0913 @@ -40,20 +42,23 @@ def __init__( # noqa: PLR0913 ) def __call__(self, read_write_mode: ReadWriteMode): - """Get read/write lock object with the specified ``read_write_mode``. + """ + Get read/write lock object with the specified ``read_write_mode``. :param read_write_mode: whether this object should be in WRITE mode or READ mode. :return: a lock object in specified ``read_write_mode``. """ if read_write_mode == ReadWriteMode.READ: return self.read_lock - elif read_write_mode == ReadWriteMode.WRITE: + if read_write_mode == ReadWriteMode.WRITE: return self.write_lock + return None class _DisabledReadWriteFileLockWrapper(BaseReadWriteFileLockWrapper): def __new__(cls): - raise NotImplementedError("ReadWriteFileLock is unavailable.") + msg = "ReadWriteFileLock is unavailable." + raise NotImplementedError(msg) __all__ = [