Missing default return value for typer.Option #574
-
First Check
Commit to Help
Example Codefrom typing import Optional
import typer
def main(
name: Optional[str] = typer.Option('Test', '--name', '-n'),
):
if name:
print(f"Good day Ms. {name}.")
else:
print(f"Hello World!")
if __name__ == "__main__":
typer.run(main) DescriptionWhen executing Operating SystemWindows Operating System DetailsNo response Typer Version0.6.1 Python Version3.8.10 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The idea of default value is that it will be used if user doesn't specify this option at all
|
Beta Was this translation helpful? Give feedback.
The idea of default value is that it will be used if user doesn't specify this option at all
python scratch.py -n
will not work here, because Typer needs to know the exact number of values to expect for this option.Otherwise we would have ambiguity: is the value after
-n
the value of this option or the value of another argument?