Skip to content

Commit 447c55f

Browse files
committed
doc: mention allowing T | None
1 parent 584adbb commit 447c55f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

docs/tutorial/arguments/optional.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Because we are using `typer.Argument()` **Typer** will know that this is a *CLI
108108
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`.
109109

110110
!!! tip
111-
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`.
111+
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`).
112112

113113
Check the help:
114114

0 commit comments

Comments
 (0)