Skip to content

custom_types

Decorators for manipulating function signatures.

Functions:

Name Description
method_signature_of

Set the signature of the decorated function to the signature of the given function, but preserve the first parameter of the

return_of

Copy only the return type of the given function.

signature_of

Return a decorator that sets the signature of the decorated function to the signature of the given function.

method_signature_of

method_signature_of(
    _: Callable[Concatenate[Any, P], Any],
) -> Callable[
    [Callable[Concatenate[T, ...], R]],
    Callable[Concatenate[T, P], R],
]

Set the signature of the decorated function to the signature of the given function, but preserve the first parameter of the signature. Use this when decorating methods.

Returns:

Type Description
Callable[[Callable[Concatenate[T, ...], R]], Callable[Concatenate[T, P], R]]

A signature changing decorator.

return_of

return_of(
    _: Callable[..., T],
) -> Callable[[Callable[P, Any]], Callable[P, T]]

Copy only the return type of the given function.

Returns:

Type Description
Callable[[Callable[P, Any]], Callable[P, T]]

A signature changing decorator.

signature_of

signature_of(
    _: Callable[P, Any],
) -> Callable[[Callable[..., R]], Callable[P, R]]

Return a decorator that sets the signature of the decorated function to the signature of the given function.

Returns:

Type Description
Callable[[Callable[..., R]], Callable[P, R]]

A signature changing decorator.