@@ -43,6 +43,12 @@ enum Deprecation {
43
43
/// Deprecated imports may be removed in future versions of Python, and
44
44
/// should be replaced with their new equivalents.
45
45
///
46
+ /// Note that, in some cases, it may be preferable to continue importing
47
+ /// members from `typing_extensions` even after they're added to the Python
48
+ /// standard library, as `typing_extensions` can backport bugfixes and
49
+ /// optimizations from later Python versions. This rule thus avoids flagging
50
+ /// imports from `typing_extensions` in such cases.
51
+ ///
46
52
/// ## Example
47
53
/// ```python
48
54
/// from collections import Sequence
@@ -139,10 +145,12 @@ const TYPING_EXTENSIONS_TO_TYPING: &[&str] = &[
139
145
"ContextManager" ,
140
146
"Coroutine" ,
141
147
"DefaultDict" ,
142
- "NewType" ,
143
148
"TYPE_CHECKING" ,
144
149
"Text" ,
145
150
"Type" ,
151
+ // Introduced in Python 3.5.2, but `typing_extensions` contains backported bugfixes and
152
+ // optimizations,
153
+ // "NewType",
146
154
] ;
147
155
148
156
// Python 3.7+
@@ -168,11 +176,13 @@ const MYPY_EXTENSIONS_TO_TYPING_38: &[&str] = &["TypedDict"];
168
176
// Members of `typing_extensions` that were moved to `typing`.
169
177
const TYPING_EXTENSIONS_TO_TYPING_38 : & [ & str ] = & [
170
178
"Final" ,
171
- "Literal" ,
172
179
"OrderedDict" ,
173
- "Protocol" ,
174
- "SupportsIndex" ,
175
180
"runtime_checkable" ,
181
+ // Introduced in Python 3.8, but `typing_extensions` contains backported bugfixes and
182
+ // optimizations.
183
+ // "Literal",
184
+ // "Protocol",
185
+ // "SupportsIndex",
176
186
] ;
177
187
178
188
// Python 3.9+
@@ -243,6 +253,8 @@ const TYPING_TO_COLLECTIONS_ABC_310: &[&str] = &["Callable"];
243
253
// Members of `typing_extensions` that were moved to `typing`.
244
254
const TYPING_EXTENSIONS_TO_TYPING_310 : & [ & str ] = & [
245
255
"Concatenate" ,
256
+ "Literal" ,
257
+ "NewType" ,
246
258
"ParamSpecArgs" ,
247
259
"ParamSpecKwargs" ,
248
260
"TypeAlias" ,
@@ -258,21 +270,19 @@ const TYPING_EXTENSIONS_TO_TYPING_310: &[&str] = &[
258
270
const TYPING_EXTENSIONS_TO_TYPING_311 : & [ & str ] = & [
259
271
"Any" ,
260
272
"LiteralString" ,
261
- "NamedTuple" ,
262
273
"Never" ,
263
274
"NotRequired" ,
264
275
"Required" ,
265
276
"Self" ,
266
- "TypedDict" ,
267
- "Unpack" ,
268
277
"assert_never" ,
269
278
"assert_type" ,
270
279
"clear_overloads" ,
271
- "dataclass_transform" ,
272
280
"final" ,
273
281
"get_overloads" ,
274
282
"overload" ,
275
283
"reveal_type" ,
284
+ // Introduced in Python 3.11, but `typing_extensions` backports the `frozen_default` argument.
285
+ // "dataclass_transform",
276
286
] ;
277
287
278
288
struct ImportReplacer < ' a > {
0 commit comments