typer
typer copied to clipboard
[BUG] Type hint for show_default of typer.Option is incorrect
Describe the bug
For typer.Argument, the type hint for show_default is this: show_default: Union[bool, str] = True, for typer.Option, the type hint is this: show_default: bool = True,
For an argument, I can override the text that accompanies the default value to be something like "working directory". This permits me to do document generation including usage blocks that don't have paths from the build system in them.
For an option, I can do the same but I need to suppress type check. The functionality works regardless of the type hints.
To Reproduce
Run mypy against this code:
def docker_build(context_path: Path = typer.Argument(Path.cwd(), exists=True,
show_default=working_directory_label,
resolve_path=True),
dockerfile: Path = typer.Option(Path.cwd() / "Dockerfile", "--file", "-f", exists=True, dir_okay=False,
show_default="Dockerfile in working directory", resolve_path =True)):
pass
Environment
- OS: Centos7
- Typer Version 0.3.1
- Python version: 3.6.8
Since it seems like the other PR might be slowed down by introducing other functionality, I created a PR solely to address this issue.