Functions
awaiting(awaitable: Awaitable[T]) -> T
async
Wraps an awaitable into a coroutine.
This function is useful in, for example, asyncio
,
where some functions expect coroutines only.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
awaitable |
Awaitable[T]
|
The awaitable to wrap. |
required |
Returns:
Type | Description |
---|---|
T
|
The result of |
Source code in src/funcs/functions.py
20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
asyncify(function: Callable[P, R]) -> AsyncCallable[P, R]
Wraps the synchronous function to be called asynchronously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function |
Callable[P, R]
|
The synchronous function to wrap. |
required |
Returns:
Type | Description |
---|---|
AsyncCallable[P, R]
|
The wrapped asynchronous function. |
Source code in src/funcs/functions.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
identity(item: T) -> T
Returns the given item
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
T
|
The item to return. |
required |
Returns:
Type | Description |
---|---|
T
|
The given item. |
Source code in src/funcs/functions.py
52 53 54 55 56 57 58 59 60 61 |
|
returns(item: T) -> Nullary[T]
Creates a function that returns the given item
when called.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
T
|
The item to return. |
required |
Returns:
Type | Description |
---|---|
Nullary[T]
|
The function that returns the given item. |
Source code in src/funcs/functions.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
raises(error: AnyError) -> Nullary[Never]
Creates a function that always raises the given error
when called.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
error |
AnyError
|
The error to raise. |
required |
Returns:
Type | Description |
---|---|
Nullary[Never]
|
The function that always raises the given error. |
Source code in src/funcs/functions.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
flip(binary: Binary[T, U, R]) -> Binary[U, T, R]
Creates a function that flips arguments of the given binary
function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
binary |
Binary[T, U, R]
|
The binary function to flip. |
required |
Returns:
Type | Description |
---|---|
Binary[U, T, R]
|
The flipped binary function. |
Source code in src/funcs/functions.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
complement(predicate: GenericPredicate[P]) -> GenericPredicate[P]
Wraps the given predicate
to return the negated result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predicate |
GenericPredicate[P]
|
The predicate to wrap. |
required |
Returns:
Type | Description |
---|---|
GenericPredicate[P]
|
The wrapped predicate. |
Source code in src/funcs/functions.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|