Skip to content

Commit 62abb62

Browse files
anpolrgommers
authored andcommitted
Use 'from typer import' for conciseness
When describing a CLI command with `typer`, it might be more common to use unqualified names, especially when you are defining many command parameters and want to avoid repetitive typing.
1 parent d380ef6 commit 62abb62

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎source/guides/creating-command-line-tools.rst‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ named after the main module:
3535

3636
.. code-block:: python
3737
38-
import typer
38+
from typer import Argument, Option
3939
from typing_extensions import Annotated
4040
4141
4242
def greet(
43-
name: Annotated[str, typer.Argument(help="The (last, if --title is given) name of the person to greet")] = "",
44-
title: Annotated[str, typer.Option(help="The preferred title of the person to greet")] = "",
45-
doctor: Annotated[bool, typer.Option(help="Whether the person is a doctor (MD or PhD)")] = False,
46-
count: Annotated[int, typer.Option(help="Number of times to greet the person")] = 1
43+
name: Annotated[str, Argument(help="The (last, if --title is given) name of the person to greet")] = "",
44+
title: Annotated[str, Option(help="The preferred title of the person to greet")] = "",
45+
doctor: Annotated[bool, Option(help="Whether the person is a doctor (MD or PhD)")] = False,
46+
count: Annotated[int, Option(help="Number of times to greet the person")] = 1
4747
):
4848
greeting = "Greetings, "
4949
if doctor and not title:

0 commit comments

Comments
 (0)