selfdependent()
Decorator that converts an instance method into a FastAPI dependency using a SelfDependent
descriptor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
factory |
Dependency[TOwner] | None
|
An optional factory (and FastAPI dependency) that can be wrapped in |
None
|
Source code in fasted/selfdependent.py
SelfDependent
Bases: Generic[TOwner, TParams, TResult]
Descriptor whose value is a method (FastAPI dependency) with an annotated
self
argument that can be processed and used by FastAPI as a dependency.
Source code in fasted/selfdependent.py
__init__(wrapped, *, factory=None)
Initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wrapped |
Callable[Concatenate[TOwner, TParams], TResult]
|
The wrapped function. |
required |
factory |
Dependency[TOwner] | None
|
An optional factory for creating |
None
|
Source code in fasted/selfdependent.py
SelfWrapper
SelfDependent
function wrappers that populate the self
argument of the wrapped function
from the keyword arguments (if one was provided), or use the owner instance if one wasn't
provided. Thus the wrapped "static" methods can behave as if they were instance methods.
Source code in fasted/selfdependent.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
async_generator(func, owner)
classmethod
Wrapper for asynchronous generator methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable[Concatenate[TOwner, TParams], AsyncGenerator[TResult, None]]
|
The function to wrap. |
required |
owner |
TOwner | None
|
An optional owner object. |
required |
Returns:
Type | Description |
---|---|
Callable[TParams, AsyncGenerator[TResult, None]]
|
The wrapper. |
Source code in fasted/selfdependent.py
async_method(func, owner)
classmethod
Wrapper for asynchronous methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable[Concatenate[TOwner, TParams], Coroutine[None, None, TResult]]
|
The function to wrap. |
required |
owner |
TOwner | None
|
An optional owner object. |
required |
Returns:
Type | Description |
---|---|
Callable[TParams, Coroutine[None, None, TResult]]
|
The wrapper. |
Source code in fasted/selfdependent.py
sync_generator(func, owner)
classmethod
Wrapper for synchronous generator methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable[Concatenate[TOwner, TParams], Generator[TResult, Any, Any]]
|
The function to wrap. |
required |
owner |
TOwner | None
|
An optional owner object. |
required |
Returns:
Type | Description |
---|---|
Callable[TParams, Generator[TResult, None, None]]
|
The wrapper. |
Source code in fasted/selfdependent.py
sync_method(func, owner)
classmethod
Wrapper for synchronous methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable[Concatenate[TOwner, TParams], TResult]
|
The function to wrap. |
required |
owner |
TOwner | None
|
An optional owner object. |
required |
Returns:
Type | Description |
---|---|
Callable[TParams, TResult]
|
The wrapper. |