Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Yard1 committed Dec 2, 2024
1 parent 2d08ebc commit eac9062
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
nitpicky = True
nitpick_ignore = [("py_class", "filelock.asyncio.AsyncReleasable"), ("py_class", "filelock._api.Releasable")]
nitpick_ignore = [("py:class", "filelock.asyncio.AsyncReleasable"), ("py:class", "filelock._api.Releasable")]
extlinks = {
"issue": ("https://github.com/tox-dev/py-filelock/issues/%s", "issue #%s"),
"pr": ("https://github.com/tox-dev/py-filelock/issues/%s", "PR #%s"),
Expand Down
20 changes: 20 additions & 0 deletions src/filelock/read_write/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
AsyncReadWriteFileLock,
AsyncReadWriteFileLockWrapper,
BaseAsyncReadWriteFileLock,
BaseAsyncReadWriteFileLockWrapper,
UnixAsyncReadWriteFileLock,
UnixAsyncReadWriteFileLockWrapper,
)

if TYPE_CHECKING:
Expand All @@ -28,16 +31,27 @@
if has_fcntl:

class UnixReadWriteFileLock(BaseReadWriteFileLock):
"""Unix implementation of a read/write FileLock."""

_shared_file_lock_cls: type[BaseFileLock] = NonExclusiveUnixFileLock
_exclusive_file_lock_cls: type[BaseFileLock] = UnixFileLock

class UnixReadWriteFileLockWrapper(BaseReadWriteFileLockWrapper):
"""Wrapper for a Unix implementation of a read/write FileLock."""

_read_write_file_lock_cls = UnixReadWriteFileLock

ReadWriteFileLock = UnixReadWriteFileLock
ReadWriteFileLockWrapper = UnixReadWriteFileLockWrapper
has_read_write_file_lock = True
else:

class UnixReadWriteFileLock(BaseReadWriteFileLock):
"""Unix implementation of a read/write FileLock."""

class UnixReadWriteFileLockWrapper(BaseReadWriteFileLockWrapper):
"""Wrapper for a Unix implementation of a read/write FileLock."""

ReadWriteFileLock = _DisabledReadWriteFileLock
ReadWriteFileLockWrapper = _DisabledReadWriteFileLockWrapper
has_read_write_file_lock = False
Expand All @@ -47,9 +61,15 @@ class UnixReadWriteFileLockWrapper(BaseReadWriteFileLockWrapper):
"AsyncReadWriteFileLock",
"AsyncReadWriteFileLockWrapper",
"BaseAsyncReadWriteFileLock",
"BaseAsyncReadWriteFileLockWrapper",
"BaseReadWriteFileLock",
"BaseReadWriteFileLockWrapper",
"ReadWriteFileLock",
"ReadWriteFileLockWrapper",
"ReadWriteMode",
"UnixAsyncReadWriteFileLock",
"UnixAsyncReadWriteFileLockWrapper",
"UnixReadWriteFileLock",
"UnixReadWriteFileLockWrapper",
"has_read_write_file_lock",
]
8 changes: 7 additions & 1 deletion src/filelock/read_write/_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@


class BaseReadWriteFileLockWrapper(ABC):
"""
Convenience wrapper for read/write locks.
Provides `.read()` and `.write()` methods to easily access a read or write lock.
"""

_read_write_file_lock_cls: type[BaseReadWriteFileLock]

def __init__( # noqa: PLR0913
Expand All @@ -26,7 +32,7 @@ def __init__( # noqa: PLR0913
"""
Convenience wrapper for read/write locks.
See filelock.read_write.ReadWriteFileLock for description of the parameters.
See ReadWriteFileLock for description of the parameters.
"""
self.read_lock = self._read_write_file_lock_cls(
lock_file=lock_file,
Expand Down
18 changes: 16 additions & 2 deletions src/filelock/read_write/asyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,26 @@
if has_fcntl:

class UnixAsyncReadWriteFileLock(BaseAsyncReadWriteFileLock):
"""Unix implementation of an async read/write FileLock."""

_shared_file_lock_cls: type[BaseAsyncFileLock] = AsyncNonExclusiveUnixFileLock
_exclusive_file_lock_cls: type[BaseAsyncFileLock] = AsyncUnixFileLock

class UnixReadWriteFileLockWrapper(BaseAsyncReadWriteFileLockWrapper):
class UnixAsyncReadWriteFileLockWrapper(BaseAsyncReadWriteFileLockWrapper):
"""Wrapper for a Unix implementation of an async read/write FileLock."""

_read_write_file_lock_cls = UnixAsyncReadWriteFileLock

AsyncReadWriteFileLock = UnixAsyncReadWriteFileLock
AsyncReadWriteFileLockWrapper = UnixReadWriteFileLockWrapper
AsyncReadWriteFileLockWrapper = UnixAsyncReadWriteFileLockWrapper
else:

class UnixAsyncReadWriteFileLock(BaseAsyncReadWriteFileLock):
"""Unix implementation of an async read/write FileLock."""

class UnixAsyncReadWriteFileLockWrapper(BaseAsyncReadWriteFileLockWrapper):
"""Wrapper for a Unix implementation of an async read/write FileLock."""

AsyncReadWriteFileLock = _DisabledAsyncReadWriteFileLock
AsyncReadWriteFileLockWrapper = _DisabledAsyncReadWriteFileLockWrapper

Expand All @@ -45,4 +56,7 @@ class UnixReadWriteFileLockWrapper(BaseAsyncReadWriteFileLockWrapper):
"AsyncReadWriteFileLock",
"AsyncReadWriteFileLockWrapper",
"BaseAsyncReadWriteFileLock",
"BaseAsyncReadWriteFileLockWrapper",
"UnixAsyncReadWriteFileLock",
"UnixAsyncReadWriteFileLockWrapper",
]
3 changes: 1 addition & 2 deletions src/filelock/read_write/asyncio/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async def acquire( # type: ignore[override]
Try to acquire the file lock.
:param timeout: maximum wait time for acquiring the lock, ``None`` means use the default
:attr:`~BaseFileLock.timeout` is and if ``timeout < 0``, there is no timeout and
:attr:`filelock.BaseFileLock.timeout` is and if ``timeout < 0``, there is no timeout and
this method will block until the lock could be acquired
:param poll_interval: interval of trying to acquire the lock file
:param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the
Expand Down Expand Up @@ -237,5 +237,4 @@ def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def] #

__all__ = [
"BaseAsyncReadWriteFileLock",
"_DisabledAsyncReadWriteFileLock",
]
1 change: 1 addition & 0 deletions src/filelock/read_write/asyncio/_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class BaseAsyncReadWriteFileLockWrapper(BaseReadWriteFileLockWrapper):
"""
Convenience wrapper class for async read/write locks.
Provides `.read()` and `.write()` methods to easily access a read or write lock.
"""

Expand Down

0 comments on commit eac9062

Please sign in to comment.