diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-09-27 19:42:29 (GMT) |
---|---|---|
committer | Ćukasz Langa <lukasz@langa.pl> | 2020-10-04 15:30:48 (GMT) |
commit | 900b9851ff93c695300af69cf5f2793a6750f781 (patch) | |
tree | 48c770379b9611c11f4e7006f6a4195c2597670d /Doc/glossary.rst | |
parent | a5750cf43466f5913cdeef774f7c2dcb5943d408 (diff) | |
download | cpython-900b9851ff93c695300af69cf5f2793a6750f781.zip cpython-900b9851ff93c695300af69cf5f2793a6750f781.tar.gz cpython-900b9851ff93c695300af69cf5f2793a6750f781.tar.bz2 |
[doc] Leverage the fact that the actual types can now be indexed for typing (GH-22340)
This shows users that they can use the actual types. Using deprecated types is confusing.
This also prefers colections.abc.Sized instead of the alias typing.Sized. I guess the aliases were created to make it convenient to import all collections related types from the same place.
This should be backported to 3.9.
Automerge-Triggered-By: @gvanrossum
(cherry picked from commit d9ab95ff1fe81efdf70e545d536d9f6927d1ba81)
Co-authored-by: Andre Delfino <adelfino@gmail.com>
Diffstat (limited to 'Doc/glossary.rst')
-rw-r--r-- | Doc/glossary.rst | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 7be755e..9fdbdb1 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -1084,19 +1084,15 @@ Glossary Type aliases are useful for simplifying :term:`type hints <type hint>`. For example:: - from typing import List, Tuple - def remove_gray_shades( - colors: List[Tuple[int, int, int]]) -> List[Tuple[int, int, int]]: + colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]: pass could be made more readable like this:: - from typing import List, Tuple - - Color = Tuple[int, int, int] + Color = tuple[int, int, int] - def remove_gray_shades(colors: List[Color]) -> List[Color]: + def remove_gray_shades(colors: list[Color]) -> list[Color]: pass See :mod:`typing` and :pep:`484`, which describe this functionality. |