@@ -126,6 +126,48 @@ See [PEP 484](http://www.python.org/dev/peps/pep-0484/) for the exact
126
126
syntax of the stub files and [ below] ( #stub-file-coding-style ) for the
127
127
coding style used in typeshed.
128
128
129
+ ### Supported type system features
130
+
131
+ Since PEP 484 was accepted, there have been many other PEPs that added
132
+ new features to the Python type system. In general, new features can
133
+ be used in typeshed as soon as the PEP has been accepted and implemented
134
+ and most type checkers support the new feature.
135
+
136
+ Accepted features that * cannot* yet be used in typeshed include:
137
+ - [ PEP 570] ( https://www.python.org/dev/peps/pep-0570/ ) (positional-only
138
+ arguments): see [ #4972 ] ( https://github.com/python/typeshed/issues/4972 ) ,
139
+ use argument names prefixed with ` __ ` instead
140
+ - [ PEP 585] ( https://www.python.org/dev/peps/pep-0585/ ) (builtin
141
+ generics): see [ #4820 ] ( https://github.com/python/typeshed/issues/4820 ) ,
142
+ mostly supported but bugs remain for a few specific cases
143
+ - [ PEP 604] ( https://www.python.org/dev/peps/pep-0604/ ) (Union
144
+ pipe operator): see [ #4819 ] ( https://github.com/python/typeshed/issues/4819 )
145
+ - [ PEP 612] ( https://www.python.org/dev/peps/pep-0612/ ) (ParamSpec):
146
+ see [ #4827 ] ( https://github.com/python/typeshed/issues/4827 )
147
+ - [ PEP 613] ( https://www.python.org/dev/peps/pep-0613/ ) (TypeAlias):
148
+ see [ #4913 ] ( https://github.com/python/typeshed/issues/4913 )
149
+
150
+ Supported features include:
151
+ - [ PEP 544] ( https://www.python.org/dev/peps/pep-0544/ ) (Protocol)
152
+ - [ PEP 586] ( https://www.python.org/dev/peps/pep-0586/ ) (Literal)
153
+ - [ PEP 591] ( https://www.python.org/dev/peps/pep-0591/ ) (Final/@final )
154
+ - [ PEP 589] ( https://www.python.org/dev/peps/pep-0589/ ) (TypedDict)
155
+ - [ PEP 647] ( https://www.python.org/dev/peps/pep-0647/ ) (TypeGuard):
156
+ see [ #5406 ] ( https://github.com/python/typeshed/issues/5406 )
157
+
158
+ Features from the ` typing ` module that are not present in all
159
+ supported Python 3 versions must be imported from ` typing_extensions `
160
+ instead in typeshed stubs. This currently affects:
161
+
162
+ - ` Final ` and ` @final ` (new in Python 3.8)
163
+ - ` Literal ` (new in Python 3.8)
164
+ - ` SupportsIndex ` (new in Python 3.8)
165
+ - ` TypedDict ` (new in Python 3.8)
166
+ - ` TypeGuard ` (new in Python 3.10)
167
+
168
+ An exception is ` Protocol ` : although it was added in Python 3.8, it
169
+ can be used in stubs regardless of Python version.
170
+
129
171
### What to include
130
172
131
173
Stubs should include the complete interface (classes, functions,
0 commit comments