Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions peps/pep-0781.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ Static type checkers must treat ``TYPE_CHECKING`` as ``True``, similar to
:data:`typing.TYPE_CHECKING`.

If this PEP is accepted, the new ``TYPE_CHECKING`` constant will be
the preferred approach, instead of the existing ``typing.TYPE_CHECKING``.
However, ``typing.TYPE_CHECKING`` will not be deprecated in the foreseeable
future.
the preferred approach and importing ``typing.TYPE_CHECKING`` will be
deprecated.
To minimize the runtime impact of typing, this deprecation will generate
``DeprecationWarning`` no sooner than Python 3.13's end of life, scheduled
for October 2029.

Instead, type checkers may warn about such deprecated usage when the target
version of the checked program is signalled to be Python 3.14 or newer.


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


Optimize ``import typing``
--------------------------

Future optimizations may eliminate the need to avoid importing the ``typing``
module for startup time.

Even with such optimizations, there will still be use cases where minimizing
imports is beneficial, such as running Python on embedded systems or
in browsers.

Therefore, defining a constant for skipping type-checking-only code outside
the ``typing`` module remains valuable.


Copyright
=========

Expand Down