Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 23, 2024
1 parent efd8de1 commit b31ce04
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/filelock/read_write/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions src/filelock/read_write/_wrapper.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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__ = [
Expand Down

0 comments on commit b31ce04

Please sign in to comment.