aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rittau <srittau@rittau.biz>2022-02-12 03:12:06 +0100
committerGitHub <noreply@github.com>2022-02-11 18:12:06 -0800
commite982c967c94943327252bccdba4436cd624b301a (patch)
treefb0832e8dd551227985e4e52cbe1b3e15bb3ca8c
parent9403ccf18c826d2028841bea77ea66c3f6045f7b (diff)
downloadtyping-e982c967c94943327252bccdba4436cd624b301a.tar.gz
Built-in generic now work without limitations (#1068)
Closes: #1067
-rw-r--r--docs/source/stubs.rst19
1 files changed, 10 insertions, 9 deletions
diff --git a/docs/source/stubs.rst b/docs/source/stubs.rst
index 161d679..8408c80 100644
--- a/docs/source/stubs.rst
+++ b/docs/source/stubs.rst
@@ -174,18 +174,20 @@ Type checkers support cyclic imports in stub files.
Built-in Generics
-----------------
-PEP 585 [#pep585]_ built-in generics are generally supported, with
-the following exceptions [#ts-4820]_:
+PEP 585 [#pep585]_ built-in generics are supported and should be used instead
+of the corresponding types from ``typing``::
-* Built-in generics don't work in type aliases.
-* Built-in generics don't work in base classes.
-* ``type`` is not supported.
-* Variable length tuples (``tuple[X, ...]``) are not supported.
+ from collections import defaultdict
-In these cases, the appropriate types from ``typing`` must be used.
+ def foo(t: type[MyClass]) -> list[int]: ...
+ x: defaultdict[int]
Using imports from ``collections.abc`` instead of ``typing`` is
-generally possible and recommended.
+generally possible and recommended::
+
+ from collections.abc import Iterable
+
+ def foo(iter: Iterable[int]) -> None: ...
Unions
------
@@ -1102,7 +1104,6 @@ Bugs
----
.. [#ts-4819] typeshed issue #4819 -- PEP 604 tracker (https://github.com/python/typeshed/issues/4819)
-.. [#ts-4820] typeshed issue #4820 -- PEP 585 tracker (https://github.com/python/typeshed/issues/4820)
.. [#ts-4913] typeshed issue #4913 -- PEP 613 tracker (https://github.com/python/typeshed/issues/4913)
.. [#ts-4972] typeshed issue #4972 -- PEP 570 tracker (https://github.com/python/typeshed/issues/4972)