Support partial'd target in builds
#199
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To-Do
instantiate(builds(partial(A)))
resolves toA
builds
This PR
Closes #197
builds
now can accept a "partial'd" object as a target 🚀 🚀 🚀Consider the following:
Before:
After:
Implementation Details
builds
"unpacks" the partial'd target and treats the.args
and.keywords
of the partial'd target as if they were specified as configured values.However, these are always treated as "inner" arguments, so that if a keyword argument is also specified by the user, it takes priority.
E.g.
this behavior is chosen specifically to have parity with
partial
:This "unpacking" behavior is really nice. We can still validate partial'd objects:
and our other bells and whistles work too:
One design decision here is that we do not "hide" any of the partial'd fields from the user. E.g. in
for
builds(partial_f, populate_full_signature=True)
we could excludex
from the__init__
/signature of the config. This would add some complications to the implementation, but the more pressing reason for why we didn't do this is that it would disrupt our parity withfunctools.partial
. As demonstrated above, one can name a field even after it has been named within the partial: