Provide support for functools.partial
within config-creation funcs
#197
Labels
enhancement
New feature or request
functools.partial
within config-creation funcs
#197
Note that this issue is not describing support for creating a partial-config; we already have this capability:
rather it is about accommodating user-supplied/default values and builds-targets that are themselves partial'd targets.
Supporting
builds(functools.partial(<target>, ...), ...)
Currently, attempting to use
builds
on a "partial'd" target raises an error because the__name__
of the object cannot be resolved (which is needed to determine_target_
):We can actually support this by "unpacking" the partial'd object. Under the hood,
builds
can detect iftarget
"looks like" a partial and do:so that we get:
As an aside, we should improve our error-reporting in this case. The reported attribute error will likely not lead users to a solution.
Supporting
builds(target, x=functools.partial(func, a=1))
We can also support cases where a configured field is itself a partial'd object. We can similarly "unpack" the partial, but this time we will apply
zen_partial=True
so that the config instantiates back to the partial'd object.E.g.
will effectively be equivalent to
so that
The text was updated successfully, but these errors were encountered: