Skip to content

typing¤

Custom type annotations.

FutureOrResult ¤

Bases: Protocol

The reply to a request.

__call__ ¤

__call__(*args: Any, sync: Literal[True] = True, **kwargs: Any) -> Any
__call__(*args: Any, sync: Literal[False] = False, **kwargs: Any) -> Future[Any]
__call__(*args: Any, sync: bool = True, **kwargs: Any) -> Any | Future[Any]

Call a method of a Service.

Parameters:

Name Type Description Default
*args Any

The arguments that the method of the Service requires.

()
sync bool

Whether to perform a synchronous request or an asynchronous request.

True
**kwargs Any

The keyword arguments that the method of the Service requires.

{}

Returns:

Type Description
Any | Future[Any]

Depending on the value of the sync keyword argument, the returned value is the result (sync=True) for a synchronous request or a Future (sync=False) for an asynchronous request, which will eventually contain the result of the request that the future represents.

Source code in src/msl/network/typing.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def __call__(self, *args: Any, sync: bool = True, **kwargs: Any) -> Any | Future[Any]:
    """Call a method of a [Service][].

    Args:
        *args: The arguments that the method of the [Service][] requires.
        sync: Whether to perform a synchronous request or an asynchronous request.
        **kwargs: The keyword arguments that the method of the [Service][] requires.

    Returns:
        Depending on the value of the `sync` keyword argument, the returned value is the
            result (`sync=True`) for a synchronous request or a [Future][concurrent.futures.Future]
            (`sync=False`) for an asynchronous request, which will eventually contain the
            [result][concurrent.futures.Future.result] of the request that the future represents.
    """

PathLike module-attribute ¤