Skip to content

Commit b394f88

Browse files
authored
PEP 781: Add deprecation and a rejected idea (#4341)
1 parent 49d6cdc commit b394f88

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

peps/pep-0781.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@ Static type checkers must treat ``TYPE_CHECKING`` as ``True``, similar to
6363
:data:`typing.TYPE_CHECKING`.
6464

6565
If this PEP is accepted, the new ``TYPE_CHECKING`` constant will be
66-
the preferred approach, instead of the existing ``typing.TYPE_CHECKING``.
67-
However, ``typing.TYPE_CHECKING`` will not be deprecated in the foreseeable
68-
future.
66+
the preferred approach and importing ``typing.TYPE_CHECKING`` will be
67+
deprecated.
68+
To minimize the runtime impact of typing, this deprecation will generate
69+
``DeprecationWarning`` no sooner than Python 3.13's end of life, scheduled
70+
for October 2029.
71+
72+
Instead, type checkers may warn about such deprecated usage when the target
73+
version of the checked program is signalled to be Python 3.14 or newer.
6974

7075

7176
Backwards Compatibility
@@ -115,6 +120,20 @@ Benefit from eliminating type-checking-only code is estimated to be not enough
115120
to justify the complexity.
116121

117122

123+
Optimize ``import typing``
124+
--------------------------
125+
126+
Future optimizations may eliminate the need to avoid importing the ``typing``
127+
module for startup time.
128+
129+
Even with such optimizations, there will still be use cases where minimizing
130+
imports is beneficial, such as running Python on embedded systems or
131+
in browsers.
132+
133+
Therefore, defining a constant for skipping type-checking-only code outside
134+
the ``typing`` module remains valuable.
135+
136+
118137
Copyright
119138
=========
120139

0 commit comments

Comments
 (0)