provider
Classes:
-
AsyncProvider–A provider for a dependency.
-
SyncProvider–A provider for a dependency.
Functions:
-
asynccontextmanager–Create a provider from the given async iterator function.
-
asyncfunction–Create a provider from the given coroutine.
-
contextmanager–Create a provider from the given iterator function.
-
function–Create a provider from the given function.
Attributes:
Provider
module-attribute
Provider: TypeAlias = (
"SyncProvider[P, R] | AsyncProvider[P, R]"
)
A provider for a dependency.
AsyncProvider
AsyncProvider(
producer: AsyncContextManagerCallable[P, R],
provides: Hint | InferHint,
dependencies: HintMap,
)
SyncProvider
SyncProvider(
producer: ContextManagerCallable[P, R],
provides: Hint | InferHint,
dependencies: HintMap,
)
asynccontextmanager
asynccontextmanager(
func: AsyncIteratorCallable[P, R],
*,
requires: HintMap | HintSeq | None = None,
provides: Hint | InferHint | None = None
) -> AsyncProvider[P, R]
Create a provider from the given async iterator function.
Parameters:
-
(funcAsyncIteratorCallable[P, R]) –The function to create a provider from.
-
(requiresHintMap | HintSeq | None, default:None) –The dependencies of the function (infered if not provided).
-
(providesHint | InferHint | None, default:None) –The type that the function provides (infered if not provided).
asyncfunction
asyncfunction(
func: Callable[P, Awaitable[R]],
*,
requires: HintMap | HintSeq | None = None,
provides: Hint | InferHint | None = None
) -> AsyncProvider[P, R]
Create a provider from the given coroutine.
Parameters:
-
(funcCallable[P, Awaitable[R]]) –The function to create a provider from.
-
(requiresHintMap | HintSeq | None, default:None) –The dependencies of the function (infered if not provided).
-
(providesHint | InferHint | None, default:None) –The type that the function provides (infered if not provided).
contextmanager
contextmanager(
func: IteratorCallable[P, R],
*,
requires: HintMap | HintSeq | None = None,
provides: Hint | InferHint | None = None
) -> SyncProvider[P, R]
Create a provider from the given iterator function.
Parameters:
-
(funcIteratorCallable[P, R]) –The function to create a provider from.
-
(requiresHintMap | HintSeq | None, default:None) –The dependencies of the function (infered if not provided).
-
(providesHint | InferHint | None, default:None) –The type that the function provides (infered if not provided).