Conversation
Parameter.consume_value pulled the parameter default unconditionally, so default callbacks (and other defaults) were evaluated even when ctx.resilient_parsing was enabled during shell completion. The docs state that defaults are ignored in resilient parsing mode. Honor that flag when sourcing the default value. fixes pallets#2614
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2614
Parameter.consume_valuesourced the parameter's default value unconditionally. As a result, default callbacks (and other defaults) were evaluated even during shell completion, wherectx.resilient_parsingis enabled.The
Context.resilient_parsingdocs state that in this mode "Default values will also be ignored. This is useful for implementing things such as completion support." This change honors that flag when sourcing the default, so expensive default callbacks are no longer called while generating completions.Changes
consume_valueonly applies the parameter default whennot ctx.resilient_parsing.ShellCompletegenerates completions.CHANGES.rstentry and a.. versionchanged::note.The full test suite passes (1668 passed, 0 regressions).