Skip to content

Commit

Permalink
doc: mention allowing T | None
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoeggy committed Jan 3, 2023
1 parent 584adbb commit 447c55f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/tutorial/arguments/optional.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Because we are using `typer.Argument()` **Typer** will know that this is a *CLI
And because the first parameter passed to `typer.Argument(None)` (the new "default" value) is `None`, **Typer** knows that this is an **optional** *CLI argument*, if no value is provided when calling it in the command line, it will have that default value of `None`.

!!! tip
By using `Optional` your editor will be able to know that the value *could* be `None`, and will be able to warn you if you do something assuming it is a `str` that would break if it was `None`.
By using `Optional` your editor will be able to know that the value *could* be `None`, and will be able to warn you if you do something assuming it is a `str` that would break if it was `None`. If you are using Python 3.10 or newer, you can also use `T | None` instead of `Optional[T]` (e.g., `str | None`).

Check the help:

Expand Down

0 comments on commit 447c55f

Please sign in to comment.