Skip to content
Myr

🐛 Update type annotations for `show_default` parameter and update docs for setting a "Custom default string" (#501)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Patrick Lannigan · committed by GitHub · parent cf61871 · Browse files · 5 files+73 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
  • Co-authored-by: svlandeg <svlandeg@github.com>

Diff stats

5 files+73 added−4 removed

  • other:+73 added−4 removed

5 files+73 added−4 removed

modified:docs/tutorial/options/help.md+42 added
added:docs_src/options/help/tutorial004_an.py+14 added
1import typer2from typing_extensions import Annotated345def main(6 fullname: Annotated[7 str, typer.Option(show_default="Deadpoolio the amazing's name")8 ] = "Wade Wilson"9):10 print(f"Hello {fullname}")111213if __name__ == "__main__":14 typer.run(main)
added:docs_src/options/help/tutorial004.py+13 added
1import typer234def main(5 fullname: str = typer.Option(6 "Wade Wilson", show_default="Deadpoolio the amazing's name"7 )8):9 print(f"Hello {fullname}")101112if __name__ == "__main__":13 typer.run(main)
modified:typer/models.py+1 added-1 removed
295 unmodified lines
296 # Custom type297 parser: Optional[Callable[[str], Any]] = None,298 click_type: Optional[click.ParamType] = None,299 # Option300 show_default: bool = True,300 show_default: Union[bool, str] = True,301 prompt: Union[bool, str] = False,302 confirmation_prompt: bool = False,303 prompt_required: bool = True,304 hide_input: bool = False,
219 unmodified lines
modified:typer/params.py+3 added-3 removed
28 unmodified lines
29 default_factory: Optional[Callable[[], Any]] = None,30 # Custom type31 parser: Optional[Callable[[str], Any]] = None,32 # Option33 show_default: bool = True,33 show_default: Union[bool, str] = True,34 prompt: Union[bool, str] = False,35 confirmation_prompt: bool = False,36 prompt_required: bool = True,37 hide_input: bool = False,
55 unmodified lines
93 default_factory: Optional[Callable[[], Any]] = None,94 # Custom type95 click_type: Optional[click.ParamType] = None,96 # Option97 show_default: bool = True,97 show_default: Union[bool, str] = True,98 prompt: Union[bool, str] = False,99 confirmation_prompt: bool = False,100 prompt_required: bool = True,101 hide_input: bool = False,
54 unmodified lines
156 # Custom type157 parser: Optional[Callable[[str], Any]] = None,158 click_type: Optional[click.ParamType] = None,159 # Option160 show_default: bool = True,160 show_default: Union[bool, str] = True,161 prompt: Union[bool, str] = False,162 confirmation_prompt: bool = False,163 prompt_required: bool = True,164 hide_input: bool = False,
304 unmodified lines