Skip to content

Commit e982c96

Browse files
authored
Built-in generic now work without limitations (#1068)
Closes: #1067
1 parent 9403ccf commit e982c96

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

docs/source/stubs.rst

+10-9
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,20 @@ Type checkers support cyclic imports in stub files.
174174
Built-in Generics
175175
-----------------
176176

177-
PEP 585 [#pep585]_ built-in generics are generally supported, with
178-
the following exceptions [#ts-4820]_:
177+
PEP 585 [#pep585]_ built-in generics are supported and should be used instead
178+
of the corresponding types from ``typing``::
179179

180-
* Built-in generics don't work in type aliases.
181-
* Built-in generics don't work in base classes.
182-
* ``type`` is not supported.
183-
* Variable length tuples (``tuple[X, ...]``) are not supported.
180+
from collections import defaultdict
184181

185-
In these cases, the appropriate types from ``typing`` must be used.
182+
def foo(t: type[MyClass]) -> list[int]: ...
183+
x: defaultdict[int]
186184

187185
Using imports from ``collections.abc`` instead of ``typing`` is
188-
generally possible and recommended.
186+
generally possible and recommended::
187+
188+
from collections.abc import Iterable
189+
190+
def foo(iter: Iterable[int]) -> None: ...
189191

190192
Unions
191193
------
@@ -1102,7 +1104,6 @@ Bugs
11021104
----
11031105

11041106
.. [#ts-4819] typeshed issue #4819 -- PEP 604 tracker (https://github.com/python/typeshed/issues/4819)
1105-
.. [#ts-4820] typeshed issue #4820 -- PEP 585 tracker (https://github.com/python/typeshed/issues/4820)
11061107
.. [#ts-4913] typeshed issue #4913 -- PEP 613 tracker (https://github.com/python/typeshed/issues/4913)
11071108
.. [#ts-4972] typeshed issue #4972 -- PEP 570 tracker (https://github.com/python/typeshed/issues/4972)
11081109

0 commit comments

Comments
 (0)