feat: add side and side_func – clean alternative to "or print()" in lambdas

This commit is contained in:
rus07tam 2025-11-23 10:14:46 +00:00
parent 6ca21a633c
commit c879b22f43
2 changed files with 14 additions and 0 deletions

View file

@ -2,6 +2,7 @@ from .attr import get_attrs, get_or_set_attr
from .frame import frame from .frame import frame
from .inherit import inherit from .inherit import inherit
from .nolock import nolock from .nolock import nolock
from .side import side, side_func
from .this import this from .this import this
from .throw import throw from .throw import throw
from .to_async import to_async from .to_async import to_async
@ -12,6 +13,8 @@ __all__ = [
"frame", "frame",
"inherit", "inherit",
"nolock", "nolock",
"side",
"side_func",
"this", "this",
"throw", "throw",
"to_async", "to_async",

11
src/snakia/utils/side.py Normal file
View file

@ -0,0 +1,11 @@
from typing import Any, Callable, TypeVar
T = TypeVar("T")
def side(value: T, *_: Any, **__: Any) -> T:
return value
def side_func(value: T, *_: Any, **__: Any) -> Callable[..., T]:
return lambda *_, **__: value