liblaf.peach.utils
¶
Runtime helpers used by Peach protocols.
Functions:
-
is_implemented–Return whether
objprovides a concrete method implementation. -
not_implemented–Mark a protocol stub as intentionally unimplemented.
is_implemented
¶
Return whether obj provides a concrete method implementation.
Parameters:
-
obj(Any) –Object to inspect.
-
method(str | Callable) –Method name or callable whose
__name__is used.
Returns:
-
bool–Falsefor missing attributes,None, or methods decorated with -
bool–not_implemented; otherwise -
bool–True.
Examples:
>>> from liblaf.peach.utils import is_implemented, not_implemented
>>> class Hooks:
... @not_implemented
... def callback(self): ...
>>> is_implemented(Hooks(), "callback")
False
>>> class Concrete:
... def callback(self): ...
>>> is_implemented(Concrete(), "callback")
True
Source code in src/liblaf/peach/utils/_implemented.py
not_implemented
¶
Mark a protocol stub as intentionally unimplemented.
The marker lets
is_implemented distinguish inherited
protocol placeholders from concrete hook implementations.