Fix a bunch of processing issues#1687
Merged
Merged
Conversation
This ensures the default value is processed like other values. Some type converters were adjusted to accept values that are already the correct type. Use parameter source instead of value to determine if argument was supplied on the command line during completion. Add a parameter source for values from prompt.
76f059b to
abee43d
Compare
If a default isn't given, return () for multiple or nargs=-1, or return None for nargs > 1.
abee43d to
ffe7a3b
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This fixes the various processing issues I noticed while investigating #1649.
multiple=Trueis set andnargs> 1,defaultmust be a list of tuples. Setting such a default is detected correctly to produce atypeofTuple.get_defaultis now tried inconsume_valuewith the other sources, rather than being tried infull_process_valueafter callingprocess_value. This makes the processing more consistent.consume_valuemust now return a(value, ParameterSource)tuple.UUIDandDateTimetypes were adjusted so that theirconvertmethod allows a value that is already the correct type. This was already the case for other types.Option.consume_valueinstead offull_process_valueto match the other sources.ParameterSource.PROMPTto track that the value was prompted for. This is currently set even if the user confirms the default value.None. This fixes an issue an argument with a default value wouldn't be completed. Also use the parameter source to check if apromptshould happen.Noneif a default was not provided andnargs> 1.multiple=Trueornargs=-1returns an empty tuple. The workaround described in Tuples as Multi Value Options throw an TypeError #472 of settingdefault=(None, None)still works, but is no longer necessary.Checklist:
CHANGES.rstsummarizing the change and linking to the issue... versionchanged::entries in any relevant code docs.pre-commithooks and fix any issues.pytestandtox, no tests failed.