-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e210cd5
commit 110f0ee
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# You can now use | for typing | ||
|
||
`|` got added to type hints >= 3.10, not needing the `typing` import anymore: | ||
|
||
- Unions can now be written as `X | Y` | ||
- Optional can now be written as `X | None` | ||
|
||
``` | ||
typing import Union, Optional | ||
def func(x: Union[int, str]) -> Optional[int]: | ||
pass | ||
# >= 3.10 | ||
# no more typing import needed | ||
def func(x: int | str) -> int | None: | ||
pass | ||
``` | ||
|
||
#typing |