Skip to content

allow multiple=True with flags#2550

Merged
davidism merged 1 commit into8.1.xfrom
multiple-flag
Jul 3, 2023
Merged

allow multiple=True with flags#2550
davidism merged 1 commit into8.1.xfrom
multiple-flag

Conversation

@davidism
Copy link
Copy Markdown
Member

@davidism davidism commented Jul 3, 2023

#2246 reported that multiple=True didn't work with flags since default=() was also required. I can't remember the original conversation around that, but instead of setting the default, #2248 made multiple=True with flags an error. Comments on the PR, as well as #2292 and #2295 reported that this broke valid uses.

This removes the error and instead sets default=() if multiple=True for flags. This works if the option is a flag due to a secondary token (-y/-n), is_flag=True, or flag_value=value.

fixes #2246
fixes #2292
fixes #2295

@davidism davidism added this to the 8.1.4 milestone Jul 3, 2023
co-authored-by: Amethyst Reese <amethyst@n7.gg>
@davidism
Copy link
Copy Markdown
Member Author

davidism commented Jul 3, 2023

OK, I did find #2247, which is essentially the same as this PR, and we closed that in favor of the error because it seemed like count=True should be more appropriate than multiple=True, is_flag=True. But that was because there were no test cases demonstrating uses of that pattern, and now people posted a bunch of examples, so I think this is the correct fix.

@davidism davidism merged commit c77966e into 8.1.x Jul 3, 2023
@davidism davidism deleted the multiple-flag branch July 3, 2023 16:31
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 18, 2023
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.

1 participant