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
New instantiators parameter of ArgumentParser.instantiate, auto_cli and FromConfigMixin.from_config, to use custom instantiators only within that call, including nested classes and partials for callables that return a class. This is recommended over the global add_instantiator, which affects other libraries that use jsonargparse.
The deprecation message of ArgumentParser.add_instantiator and the v5 migration guide now point to the new parameter.
Fixed custom instantiators with an applied_instantiation_links parameter missing links for classes nested in the init_args of another class, and for the partials that instantiate gives for callables that return a class.
These changes are also applied to the v4 branch via #994
[Medium risk] Adds optional instantiators parameter to class instantiation.
The PR is not ready to merge because auto_cli bypasses scoped instantiators for class components and fails with an existing-signature custom parser override.
The PR adds call-scoped class instantiators to parser instantiation, auto_cli, and from_config, and carries instantiator and applied-link information into nested and deferred instantiation.
Adds validation and scoped-context propagation while retaining global instantiators as fallback.
Adds coverage and documentation for nested classes, links, subcommands, and deferred callables.
The auto_cli class-component and custom-parser paths need attention before the new option works consistently.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["auto_cli(..., instantiators=...)"] --> B["parser.instantiate(cfg)"]
B --> C["Instantiate nested arguments"]
C --> D["_run_component"]
D --> E["Direct class construction"]
D --> F["Function invocation"]
E -. "Bypasses scoped instantiator" .-> G["Class component"]
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a6236e8) to head (f35a8cd).
✅ All tests successful. No failed tests found.
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
bugSomething isn't workingenhancementNew feature or requestrefactorImprovements to the quality of the code
2 participants
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?
instantiatorsparameter ofArgumentParser.instantiate,auto_cliandFromConfigMixin.from_config, to use custom instantiators only within that call, including nested classes and partials for callables that return a class. This is recommended over the globaladd_instantiator, which affects other libraries that use jsonargparse.ArgumentParser.add_instantiatorand the v5 migration guide now point to the new parameter.applied_instantiation_linksparameter missing links for classes nested in theinit_argsof another class, and for the partials thatinstantiategives for callables that return a class.These changes are also applied to the v4 branch via #994
Before submitting