-
-
Notifications
You must be signed in to change notification settings - Fork 778
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the Typer documentation, with the integrated search.
- I already searched in Google "How to X in Typer" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to Typer but to Click.
Commit to Help
- I commit to help with one of those options 👆
Example Code
import typer
app = typer.Typer(add_completion=False)
@app.command()
def main(some_param: bool = typer.Option(False, "--some-param")):
pass
@app.command()
def main2(some_param2: str = typer.Option("Testing")):
pass
if __name__ == "__main__":
app()
Description
- Create a small typer script using the code mentioned above.
- Execute script.py main --help
- Execute script.py main2 --help
- Observe that the string optional parameter has a type of
TEXT
noted, and a listed default value in the main2 command. - Observe that the boolean optional parameter has no type listed in the main command, and no default value listed, even though it has a default value of False set.
This is actually a contradiction of what's currently in the Typer documentation located here: https://typer.tiangolo.com/tutorial/parameter-types/bool/
The docs shows the following image:
It can clearly be seen that at the time of that documentation being created, it was intended for an optional parameter to be specified with a "flag" style, but also retain its default value. Testing has shown that this may be related to the upgrade from Click 7.1.2 -> Click 8.x, but I was unable to pin down whether or not this issue relates to Click itself, or if it's due to Typer's new compatibility code that uses Rich for --help menus rather than Click's help formatter.
Typer 0.4.1 and Click 7.1.2 did not show this issue when tested, but Typer 0.6.1 and Click 8.1.3 did, as does Typer 0.7 and Click 8.1.3.
Ideally the intended result would be to have the type be shown as well. So it would be --some-param BOOL [Default: False]
or something like that, to keep things consistent with all other types.
Operating System
Windows
Operating System Details
No response
Typer Version
0.7
Python Version
3.8.10
Additional Context
No response