-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Milestone
Description
When upgrading from Click 8.1.8 to 8.2.0, I encountered a bug where boolean flags are not parsed correctly.
Reproduction
The below program can reproduce the error
from sys import exit
import click
@click.command(help="help")
@click.option("-v", "--version", type=click.BOOL, default=False, is_flag=True)
@click.option("-h", "--help", type=click.BOOL, default=False, is_flag=True)
@click.option("-n", "--name", type=click.STRING, default="John Doe")
def main(help, version, name):
print(f"{help=}, {version=}, {name=}")
if help:
print("Help")
exit(0)
if version:
print("v1.0.0")
exit(0)
print(f"Hello, {name}")
if __name__ == "__main__":
main()
- When running with click 8.1.8, all flags/options are parsed as expected
- On 8.2.0, boolean flags are not parsed and remain at their default value
- e.g.
python main.py --help --name Robert
will printhelp=False, version=False, name='Robert'
- e.g.
Environment:
- OS: NixOS 24.11
- Python version: 3.12.8
- Click version: 8.2.0
I'm unsure if this is a regression in Click, or an issue on my end. Any help would be greatly appreciated. TIA!
con-fah, btschwertfeger, kyluca, henry-fn, squidarth and 10 moreiuga
Metadata
Metadata
Assignees
Labels
No labels