You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to make the help output less cluttered, it makes sense to hide the [default: None] for arguments and required options since a value must always be passed (meaning that the default doesn't really have any use).
As an aside, I supposed that the default is sometimes used as an "example," so maybe it could make sense to add an example param that could be used for this purpose?
Wanted Solution
Current help output:
❯ pdm run python typer_issue.py --help
Usage: typer_issue.py [OPTIONS] NAME
╭─ Arguments ──────────────────────────────────────────────────╮
│ * name TEXT [default: None] [required] │
╰──────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────╮
│ --option-1 TEXT [default: │
│ option_1_default] │
│ * --option-2 TEXT [default: None] │
│ [required] │
│ --install-completion Install completion for │
│ the current shell. │
│ --show-completion Show completion for the │
│ current shell, to copy │
│ it or customize the │
│ installation. │
│ --help Show this message and │
│ exit. │
╰──────────────────────────────────────────────────────────────╯
Desired help output:
❯ pdm run python typer_issue.py --help
Usage: typer_issue.py [OPTIONS] NAME
╭─ Arguments ──────────────────────────────────────────────────╮
│ * name TEXT [required] │
╰──────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────╮
│ --option-1 TEXT [default: │
│ option_1_default] │
│ * --option-2 TEXT [required] │
│ --install-completion Install completion for │
│ the current shell. │
│ --show-completion Show completion for the │
│ current shell, to copy │
│ it or customize the │
│ installation. │
│ --help Show this message and │
│ exit. │
╰──────────────────────────────────────────────────────────────╯
Wanted Code
# No changes to the way `typer` is used
Alternatives
No response
Operating System
Linux, macOS
Operating System Details
No response
Typer Version
0.6.1
Python Version
Python 3.8.14
Additional Context
Obviously, this is a personal preference. I just feel that it helps to clean up the --help output a little bit.
The text was updated successfully, but these errors were encountered:
I didn't think about it before, but it seems like an obvious solution to this is to just use show_default=False. Still, might be worth changing the default behavior.
when using show_default = False, it would be nice if a default added by the programmer [which is sometimes the reason for this] it would be nice if there is something that looks like a default e.g [default: ....] it would also be coloured grey like the normal default text [or is that too magical] I tried with rich styling but it didn't seem to work but my typer maybe too old 0.7.0...
Confirming using typer.Argument(..., show_default=False) or typer.Option(..., show_default=False) has the desired behaviour on required arguments and options with typer 0.12.5, but this is a verbose workaround.
First Check
Commit to Help
Example Code
Description
In order to make the help output less cluttered, it makes sense to hide the
[default: None]
for arguments and required options since a value must always be passed (meaning that the default doesn't really have any use).As an aside, I supposed that the
default
is sometimes used as an "example," so maybe it could make sense to add anexample
param that could be used for this purpose?Wanted Solution
Current help output:
Desired help output:
Wanted Code
# No changes to the way `typer` is used
Alternatives
No response
Operating System
Linux, macOS
Operating System Details
No response
Typer Version
0.6.1
Python Version
Python 3.8.14
Additional Context
Obviously, this is a personal preference. I just feel that it helps to clean up the
--help
output a little bit.The text was updated successfully, but these errors were encountered: