question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

option with bool type

See original GitHub issue
@click.command()
@click.option('--shout/--no-shout', default=False)
def info(shout):
    pass

info()

is ok, but

@click.command()
@click.option('--shout/--no-shout', default=False, type=bool)
def info(shout):
    pass

info()

will raise a TypeError: Got secondary option for non boolean flag.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Xevioncommented, Jun 15, 2020

The type argument only supports bool and not click.BOOL, should this be changed to support both?

https://github.com/pallets/click/blob/9cfa961deed93af69ab43b679f0a0308fd518ecc/src/click/core.py#L1780

0reactions
xinghengcommented, Feb 12, 2020

Same here. type=click.BOOL repros this bug, too. Temporarily remove the type and resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Boolean CLI Options - Typer - tiangolo
We have seen some examples of CLI options with bool , and how Typer creates --something and --no-something automatically. But we can customize...
Read more >
angular - Get boolean option values
My issue is when clicked on the dropdown I can't get the boolean value, that is true/false, but only strings "true"/"false" hence my...
Read more >
optional::OptionBool - Rust
The OptionBool type, a space-efficient Option replacement ... Maps an OptionBool to an Option<U> by applying the function over the contained bool.
Read more >
Booleans - Manual
The bool type only has two values, and is used to express a truth value. It can be either true or false ....
Read more >
argparse: boolean option pitfall (beginner - YouTube
today I show how to properly handle boolean options in argparse as well as an easy mistake to avoid!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found