Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue UserWarning when overriding Parameter name #2396

Open
edrogers opened this issue Nov 7, 2022 · 0 comments · May be fixed by #2397
Open

Issue UserWarning when overriding Parameter name #2396

edrogers opened this issue Nov 7, 2022 · 0 comments · May be fixed by #2397
Milestone

Comments

@edrogers
Copy link

edrogers commented Nov 7, 2022

When a command is given multiple parameters that use the same name, a UserWarning should be fired to highlight the conflict. Currently, the command will quietly allow one parameter to override the names of another.

(This is a slightly different problem than #1465. In that issue, True and False values were given the same names within a single parameter.)

Example of the issue:

@click.command()
@click.option("-a", "--aardvark", is_flag=True)
@click.option("-a", "--avocado", is_flag=True)
def cli(aardvark: bool = False, avocado: bool = False):
    if aardvark:
        print("Animal")
    if avocado:
        print("Fruit")

In this scenario, the short-name, -a, appears ambiguous. A warning would help the user realize the conflict they've introduced.

I'll also provide a pull request for consideration.

@edrogers edrogers linked a pull request Nov 7, 2022 that will close this issue
6 tasks
@davidism davidism added this to the 8.2.0 milestone Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants