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
{{ message }}
Repository navigation
Apply instantiators to auto_cli class components and make instantiators keyword-only - #996
auto_cli built class components directly, so custom instantiators never reached them. This applied to return_instance=True and to class-method subcommands. They now go through the instantiators passed to auto_cli and the global ones.
auto_cli now gives the instantiators to instantiate as context instead of as a keyword. A parser_class that overrides instantiate with the old signature therefore keeps working when instantiators is given.
instantiators is now keyword-only in ArgumentParser.instantiate, auto_cli and FromConfigMixin.from_config. Since v4.53.0 is unreleased, this breaks nothing, and v5 keeps the same signature.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (bc5d73c) to head (7c57311).
✅ All tests successful. No failed tests found.
[Medium risk] Changes how instantiators are passed to CLI and config functions.
The PR appears safe to merge; no actionable regression was established.
Summary
This PR routes auto_cli class-component construction through custom instantiators and makes the newly introduced instantiators parameters keyword-only.
Passes call-scoped instantiators through parser context so parser subclasses with older instantiate overrides remain compatible.
Adds coverage for class returns, class-method subcommands, global instantiators, and context isolation.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[auto_cli] --> B[Parse arguments]
B --> C[Instantiate parsed configuration]
C --> D{Class component?}
D -->|Yes| E[Select scoped, parser, or global instantiator]
E --> F[Construct class and optionally invoke method]
D -->|No| G[Invoke function component]
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?
Follow-up to #994
auto_clibuilt class components directly, so custom instantiators never reached them. This applied toreturn_instance=Trueand to class-method subcommands. They now go through the instantiators passed toauto_cliand the global ones.auto_clinow gives theinstantiatorstoinstantiateas context instead of as a keyword. Aparser_classthat overridesinstantiatewith the old signature therefore keeps working wheninstantiatorsis given.instantiatorsis now keyword-only inArgumentParser.instantiate,auto_cliandFromConfigMixin.from_config. Since v4.53.0 is unreleased, this breaks nothing, and v5 keeps the same signature.Before submitting