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

Added functionality to set flag_value correctly when using envvar #2788

Open
wants to merge 4 commits into
base: 8.1.x
Choose a base branch
from

Conversation

chips-wq
Copy link

@click.option('--upper', flag_value='upper', envvar='UPPER')
def cmd(upper):
    click.echo(upper)
    return upper

Default use

The expectation of the above code when running python cmd.py --upper is to print to stdout upper (the flag value). This is default behaviour and works correctly.

Environment variable use

What is the expectation when we run UPPER=32 python cmd.py ?

The program should still print to the screen upper, because that is the flag_value and there exists an env variable defined with the name UPPER, yet it actually prints 32, the value of the environment variable, which i don't believe is intended.

I also added a test for this functionality called test_envvar_flag_value
fixes #2746

@chips-wq chips-wq changed the base branch from main to 8.1.x October 13, 2024 20:49
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 this pull request may close these issues.

flag_value is not taken into account with envvar
1 participant