function

language.partial

def partial(func: Callable[P, R], convert: ConvertMode = 'all', recursive: bool | None = None, wrappers: typing.Sequence[typing.Any] | None = None, meta: typing.Mapping[str, typing.Any] | None = None, strict: bool = True) -> Callable[P, functools.partial[R]]

Partially apply a function with keyword arguments.

Emits a node in the canonical Hydra wire format: ``{_target_: , _partial_: true, ...}``. At instantiation time the node is materialised as ``functools.partial(func, **kwargs)``. This is fiction #2 in the lie-typing contract — see the module docstring section "The five fictions" for the table. .. note:: All kwargs supplied to the returned callable are bound *now* — this surface deliberately offers no deferral, so positional arguments are not part of the contract even though the static ``ParamSpec`` admits them. The runtime ``wrapper`` is keyword-only and will reject positionals at call time; the pyright suite under ``tests/test_language_typing.py`` locks in the kwargs-only reading.

Parameters

NameTypeDescription
funccallableThe function to partially apply.
convert = 'all'ConvertModeHydra ``_convert_`` / ``_recursive_`` knobs. See :func:`call`.
recursive = 'all'ConvertModeHydra ``_convert_`` / ``_recursive_`` knobs. See :func:`call`.
wrappers = Nonetyping.Sequence[typing.Any] | NoneForwarded to the underlying :func:`call`. See :func:`call` for the full documentation; the same limitations apply (``laco.instantiate`` does not process these keys).
meta = Nonetyping.Sequence[typing.Any] | NoneForwarded to the underlying :func:`call`. See :func:`call` for the full documentation; the same limitations apply (``laco.instantiate`` does not process these keys).
strict = ``True``boolForwarded to the underlying :func:`call`. When ``True`` (the default), unknown kwargs are rejected at config-construction time. Pass ``strict=False`` to opt out for dynamic targets.

Returns

Callable[_P, functools.partial[_R]] — A lazy callable that, when invoked with kwargs matching ``func``'s ``ParamSpec`` ``_P``, statically yields a ``functools.partial[_R]`` over ``func``'s return type ``_R``. At runtime the callable emits a :class:`DictConfig` with ``_partial_: true`` that :func:`laco.instantiate` later materialises into a real ``functools.partial(func, **kwargs)``. Positional arguments are not part of the contract: pyright will type-check them via ``_P`` but the runtime ``wrapper`` rejects them.

Source: laco/language.py:634