synchros2.callables module
- class synchros2.callables.ComposableCallable[source]
Bases:
GeneralizedCallableA generalized callable that can be composed.
- compose(func: Callable, starred: bool = False) ComposedCallable[source]
Compose this callable with the given func.
- Parameters:
func – callable to be composed, assumed synchronous.
starred – whether the func call return value requires
not. (a star expansion for composition or)
- Returns:
the composed generalized callable.
- class synchros2.callables.ComposedCallable[source]
Bases:
GeneralizedDecorator,ComposableCallable,VectorizingCallableA composition decorator that combines a generalized callable and a regular callable.
- __init__(wrapped_callable: GeneralizedCallable, composed_callable: Callable, starred: bool = False) None[source]
Initializes composed callable.
- Parameters:
wrapped_callable – the left hand side (or outer) callable.
composed_callable – the right hand side (or inner) callable.
starred – whether the inner call return value requires a star
not. (expansion for composition or)
- class synchros2.callables.GeneralizedCallable[source]
Bases:
ABCA generalized callable that allows synchronous and asynchronous execution.
- abstractmethod asynchronous(*args: Any, **kwargs: Any) Any[source]
Invoke callable asynchronously, returning a future-like object.
- class synchros2.callables.GeneralizedDecorator[source]
Bases:
GeneralizedCallableA decorator for generalized callables.
- __init__(wrapped_callable: GeneralizedCallable) None[source]
Initializes the decorator, wrapping another callable.
- class synchros2.callables.GeneralizedFunction[source]
Bases:
GeneralizedCallableA generalized callable defined by parts.
- __init__(synchronous_callable: Callable | None = None, asynchronous_callable: Callable | None = None) None[source]
Initialize generalized function.
- Parameters:
synchronous_callable – optional synchronous body.
asynchronous_callable – optional asynchronous body.
- class synchros2.callables.GeneralizedGuard[source]
Bases:
GeneralizedDecoratorA decorator that guards generalized callable invocations.
- __init__(condition: Callable[[], bool], wrapped_callable: GeneralizedCallable, message: str | None = None) None[source]
Initializes generalized guard.
- Parameters:
condition – boolean predicate to guard invocations.
wrapped_callable – the guarded callable.
message – optional human-readable message to raise whenever
hold. (the guard condition does not)
- class synchros2.callables.GeneralizedMethod[source]
Bases:
objectA data descriptor for generalized callables bound to class instances.
- class Bound[source]
Bases:
VectorizingCallable,ComposableCallableA bound generalized method callable.
- class Unbound[source]
Bases:
objectAn unbound generalized method descriptor.
- __init__(method: GeneralizedMethod) None[source]
Initialize unbound descriptor.
- Parameters:
method – associated generalized method.
- __init__(prototype: Callable, transitional: bool) None[source]
Initializes the generalized method.
- Parameters:
prototype – method prototype, usually just a signature but
the (simplifying)
overload). (function type matches the missing)
transitional – a transitional method will stick to its
invocations (prototype for default)
the
codebases. (adoption of generalized methods in existing)
- rebind(instance: Any, body: GeneralizedCallable) None[source]
Change this method’s body for the given instance.
- class synchros2.callables.GeneralizedMethodLike[source]
Bases:
Generic[P],GeneralizedMethodA generalized method that can be type annotated via user-defined protocols.
- class synchros2.callables.VectorizedCallable[source]
Bases:
GeneralizedDecorator,ComposableCallable,VectorizingCallableA vectorization decorator that aggregates multiple invocations sequentially.
- class synchros2.callables.VectorizingCallable[source]
Bases:
GeneralizedCallableA generalized callable that can be vectorized.
- property vectorized: VectorizedCallable
Get a vectorized version of this callable.
- synchros2.callables.generalized_method(func: Callable, *, spec: Type[GeneralizedMethodLike[P]]) GeneralizedMethodLike[P][source]
- synchros2.callables.generalized_method(func: Literal[None] = None, *, spec: Type[GeneralizedMethodLike[P]], transitional: bool = False) Callable[[Callable], GeneralizedMethodLike[P]]
- synchros2.callables.generalized_method(func: Callable, *, transitional: bool = False) GeneralizedMethod
- synchros2.callables.generalized_method(func: Literal[None] = None, *, transitional: bool = False) Callable[[Callable], GeneralizedMethod]
Define a generalized method by decoration.
- Parameters:
func – method function, usually just a signature but
convenience. (may also be used as an overload for)
spec – optional type annotated specification.
transitional – a transitional method will stick to its
invocations. (prototype for default)
- synchros2.callables.starmap_async(func: Callable[[...], FutureLike | FutureConvertible], iterable: Iterable[Tuple[Any, ...]]) rclpy.task.Future[source]
Transform an iterable of tuples by star expanding them and invoking an asynchronous func.
- Parameters:
func – a callable with a future-like return value.
iterable – an iterable of tuples of positional arguments for func.
- Returns:
a future-like object to the transformed iterable.