Skip to content

Allow unspecified values for composite types#767

Closed
Kamekameha wants to merge 3 commits into
pallets:masterfrom
Kamekameha:composite-fix
Closed

Allow unspecified values for composite types#767
Kamekameha wants to merge 3 commits into
pallets:masterfrom
Kamekameha:composite-fix

Conversation

@Kamekameha
Copy link
Copy Markdown

With this, behavior is (or should be) similar to when only nargs is used. The Tuple parameter type can't actually handle empty tuples and thus we get the TypeError exception about differing value length and type arity.

Hopefully this fixes #472 but I'm not sure if this is the correct approach into fixing this since composite parameter types aren't exactly required to return tuples. Besides, ideally, for nargs unequal to 1 nargs parameters should be designed on top of the Tuple parameter type, in my opinion, and like any other type without defaults, composite types should return None when unspecified in the command line (unless multiple is True, which, as is already the case, should return an empty tuple). Of course that's a way different approach and I'd rather discuss that in here first.

I'm definitely open to suggestions or something as I'm not really familiar with click's internals. All tests runs passed for me so I hope I didn't break anything.

(Also, last commit can be ignored if necessary, I just found it appropriate in this case.)

@dsully
Copy link
Copy Markdown

dsully commented May 15, 2018

@Kamekameha Thanks for the PR. Could you add some inline comments to your changes, and perhaps some documentation?

Thanks!

@davidism davidism closed this Sep 23, 2018
@davidism davidism reopened this Sep 23, 2018
@davidism davidism changed the base branch from 6.x-maintenance to master September 23, 2018 01:49
@davidism davidism mentioned this pull request Oct 12, 2020
6 tasks
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tuples as Multi Value Options throw an TypeError

3 participants