@@ -174,18 +174,20 @@ Type checkers support cyclic imports in stub files.
174
174
Built-in Generics
175
175
-----------------
176
176
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 ``: :
179
179
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
184
181
185
- In these cases, the appropriate types from ``typing `` must be used.
182
+ def foo(t: type[MyClass]) -> list[int]: ...
183
+ x: defaultdict[int]
186
184
187
185
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: ...
189
191
190
192
Unions
191
193
------
@@ -1102,7 +1104,6 @@ Bugs
1102
1104
----
1103
1105
1104
1106
.. [#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)
1106
1107
.. [#ts-4913 ] typeshed issue #4913 -- PEP 613 tracker (https://github.com/python/typeshed/issues/4913)
1107
1108
.. [#ts-4972 ] typeshed issue #4972 -- PEP 570 tracker (https://github.com/python/typeshed/issues/4972)
1108
1109
0 commit comments