Skip to content

apply_types

fast_depends.use.inject #

inject(func: None, *, cast: bool = True, extra_dependencies: Sequence[Depends] = (), pydantic_config: Optional[ConfigDict] = None, dependency_overrides_provider: Optional[Any] = dependency_provider, wrap_model: Callable[[CallModel[P, T]], CallModel[P, T]] = lambda x: x) -> _InjectWrapper[P, T]
inject(func: Callable[P, T], *, cast: bool = True, extra_dependencies: Sequence[Depends] = (), pydantic_config: Optional[ConfigDict] = None, dependency_overrides_provider: Optional[Any] = dependency_provider, wrap_model: Callable[[CallModel[P, T]], CallModel[P, T]] = lambda x: x) -> Callable[P, T]
inject(func=None, *, cast=True, extra_dependencies=(), pydantic_config=None, dependency_overrides_provider=dependency_provider, wrap_model=lambda x: x)
Source code in fast_depends/use.py
def inject(
    func: Optional[Callable[P, T]] = None,
    *,
    cast: bool = True,
    extra_dependencies: Sequence[model.Depends] = (),
    pydantic_config: Optional[ConfigDict] = None,
    dependency_overrides_provider: Optional[Any] = dependency_provider,
    wrap_model: Callable[[CallModel[P, T]], CallModel[P, T]] = lambda x: x,
) -> Union[
    Callable[P, T],
    _InjectWrapper[P, T],
]:
    decorator = _wrap_inject(
        dependency_overrides_provider=dependency_overrides_provider,
        wrap_model=wrap_model,
        extra_dependencies=extra_dependencies,
        cast=cast,
        pydantic_config=pydantic_config,
    )

    if func is None:
        return decorator

    else:
        return decorator(func)