Skip to content

Disallow use of is_flag and multiple in options#2248

Merged
davidism merged 1 commit intopallets:8.1.xfrom
amyreese:8.1.x
Apr 28, 2022
Merged

Disallow use of is_flag and multiple in options#2248
davidism merged 1 commit intopallets:8.1.xfrom
amyreese:8.1.x

Conversation

@amyreese
Copy link
Copy Markdown
Contributor

@amyreese amyreese commented Apr 5, 2022

Raises a TypeError similar to when specifying both count=True and is_flag=True.

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@davidism davidism added this to the 8.1.3 milestone Apr 5, 2022
@davidism davidism merged commit 5fd87bd into pallets:8.1.x Apr 28, 2022
@0xDEC0DE
Copy link
Copy Markdown
Contributor

0xDEC0DE commented May 11, 2022

This ends up being a breaking change, .

For instance:

@click.command
@click.option('-p', '--project', 'project', envvar='PROJECT', multiple=True)
@click.option('--all-projects', '--all', 'project', envvar='PROJECT', flag_value='all', multiple=True)
def main(project):
    ...

...has been a convenient way to provide an "all projects" shortcut in my software for years, and now it's broken with little-to-no notice.

@juledwar
Copy link
Copy Markdown

juledwar commented May 11, 2022

Agreed.

@pallets pallets locked and limited conversation to collaborators May 12, 2022
@amyreese amyreese deleted the 8.1.x branch April 9, 2023 19:42
@davidism
Copy link
Copy Markdown
Member

davidism commented Jul 3, 2023

Removed the error and set default=True instead in #2550. The example from @0xDEC0DE and other issues should be addressed by that.

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.

4 participants