Skip to content

DeleterBase

Bases: ABC

Source code in magic_storage/base/_deleter.py
class DeleterBase(ABC):
    def delete(self, __uid: str, /, *, missing_ok: bool = False) -> None:
        """Delete object with specified uid.

        Attempt to delete non-existing object KeyError will be raised unless missing_ok=True.

        Parameters
        ----------
        __uid : str
            object unique identifier.
        missing_ok : bool, optional
            ignores missing key errors, by default False
        """
        uid = make_uid(__uid)
        try:
            self._delete(uid, missing_ok=missing_ok)
        except Exception as e:
            if not missing_ok:
                raise KeyError(f"Couldn't delete {__uid}.") from e

    @abstractmethod
    def _delete(self, __uid: str, /, *, missing_ok: bool = False) -> None:
        ...

delete(__uid, /, *, missing_ok=False) #

Delete object with specified uid.

Attempt to delete non-existing object KeyError will be raised unless missing_ok=True.

Parameters:

Name Type Description Default
__uid str

object unique identifier.

required
missing_ok bool, optional

ignores missing key errors, by default False

False
Source code in magic_storage/base/_deleter.py
def delete(self, __uid: str, /, *, missing_ok: bool = False) -> None:
    """Delete object with specified uid.

    Attempt to delete non-existing object KeyError will be raised unless missing_ok=True.

    Parameters
    ----------
    __uid : str
        object unique identifier.
    missing_ok : bool, optional
        ignores missing key errors, by default False
    """
    uid = make_uid(__uid)
    try:
        self._delete(uid, missing_ok=missing_ok)
    except Exception as e:
        if not missing_ok:
            raise KeyError(f"Couldn't delete {__uid}.") from e

Last update: August 5, 2022
Created: August 5, 2022