Skip to content

apply_types

fast_depends.use.inject #

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

    if func is None:
        return decorator

    else:
        return decorator(func)

Last update: 2023-11-13