You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Values set by links applied on instantiate were not validated against the type of the target, so e.g. a compute_fn returning a wrong type silently passed an invalid value to the class. Now these values are validated. Type errors from any link also name the link (Invalid value for link '<link>': ...), both for parse and instantiate links, which makes failures much easier to trace.
Related fixes found while working on this:
link_arguments raised AttributeError when the target was a class group added with instantiate=False.
Required init_args parameters that are link targets are no longer included in the parsed namespace with a None value; the link sets them when applied.
A value given for a link target in a default (e.g. lazy_instance(Cls, p1=2)) is now removed, since the link provides it.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2d109be) to head (34ab624).
✅ All tests successful. No failed tests found.
This PR improves argument links by identifying links in type errors, validating values produced during instantiation, omitting required linked subclass parameters from parsed namespaces, removing linked values from subclass defaults, and supporting whole-group links when class instantiation is disabled.
Adds link-aware validation and error messages for parse and instantiate links.
Resolves absent required init_args targets against the selected subclass specification.
Removes link-controlled parameters from parsed values and configured defaults.
Adds documentation, changelog entries, and regression coverage for the corrected link behavior.
The new instantiation validation currently discards normalized values, leaving a type-contract gap.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
S[Instantiate source objects] --> C{Compute function?}
C -->|Yes| V[Compute linked value]
C -->|No| V
V --> A[adapt_typehints validates and may normalize]
A --> D[Normalized return value discarded]
D --> T[Original value assigned to target]
T --> I[Instantiate target object]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
What does this PR do?
Values set by links applied on instantiate were not validated against the type of the target, so e.g. a
compute_fnreturning a wrong type silently passed an invalid value to the class. Now these values are validated. Type errors from any link also name the link (Invalid value for link '<link>': ...), both for parse and instantiate links, which makes failures much easier to trace.Related fixes found while working on this:
link_argumentsraisedAttributeErrorwhen the target was a class group added withinstantiate=False.init_argsparameters that are link targets are no longer included in the parsed namespace with aNonevalue; the link sets them when applied.lazy_instance(Cls, p1=2)) is now removed, since the link provides it.Before submitting