snakia.utils

Functions

call(f, *args, **kwargs)

caller(f, *args, **kwargs)

catch(func, *exceptions[, default])

frame()

Get the current frame.

get_attrs(obj, *[, use_dir, of_class])

get_or_set_attr(obj, name, default)

inherit(type_[, attrs])

Create a new class that inherits from the given class.

nolock()

ret()

side(value, *_, **__)

side_func(value, *_, **__)

this()

Get the current function.

throw(*exceptions[, from_])

Throw an exception.

to_async(func)

Convert a sync function to an async function.

snakia.utils.call(f, *args, **kwargs)[source]
Return type:

TypeVar(T)

snakia.utils.caller(f, *args, **kwargs)[source]
Return type:

Callable[..., TypeVar(T)]

snakia.utils.catch(func, *exceptions, default=None)[source]
Return type:

Union[TypeVar(T), Any]

snakia.utils.frame()[source]

Get the current frame.

Return type:

FrameType

snakia.utils.get_attrs(obj, *, use_dir=False, of_class=False)[source]
Return type:

dict[str, Any]

snakia.utils.get_or_set_attr(obj, name, default)[source]
Return type:

TypeVar(T)

snakia.utils.inherit(type_, attrs=None, /, **kwargs)[source]

Create a new class that inherits from the given class.

Return type:

TypeVar(T, bound= type)

Args:

type_: The class to inherit from. attrs: A dictionary of attributes to add to the new class. **kwargs: Additional attributes to add to the new class.

Returns:

A new class that inherits from the given class.

snakia.utils.nolock()[source]
Return type:

None

snakia.utils.ret()[source]
Return type:

Callable[[TypeVar(T)], TypeVar(T)]

snakia.utils.side(value, *_, **__)[source]
Return type:

TypeVar(T)

snakia.utils.side_func(value, *_, **__)[source]
Return type:

Callable[..., TypeVar(T)]

snakia.utils.this()[source]

Get the current function.

Return type:

Any

snakia.utils.throw(*exceptions, from_=<class 'snakia.types.unique.Unset'>)[source]

Throw an exception.

Return type:

NoReturn

snakia.utils.to_async(func)[source]

Convert a sync function to an async function.

Return type:

Callable[[ParamSpec(P)], Awaitable[TypeVar(R)]]

Modules

attrs

exceptions

frames

funcs

gil