11PEP: 781
2- Title: Make ``TYPE_CHECKING `` builtin
2+ Title: Make ``TYPE_CHECKING `` a built-in constant
33Author: Inada Naoki <songofacandy@gmail.com>
44Discussions-To: https://discuss.python.org/t/85728
55Status: Draft
@@ -14,11 +14,11 @@ Post-History: `11-Jan-2025 <https://discuss.python.org/t/76766>`__,
1414Abstract
1515========
1616
17- This PEP proposes adding a new builtin , :data: `!TYPE_CHECKING `, to improve
17+ This PEP proposes adding a new built-in variable , :data: `!TYPE_CHECKING `, to improve
1818the experience of writing Python code with type annotations. It is evaluated
1919as ``True `` when the code is being analyzed by a static type checker, and as
2020``False `` during normal runtime execution. Unlike :data: `typing.TYPE_CHECKING `,
21- which this keyword replaces, it does not require an import statement.
21+ which this variable replaces, it does not require an import statement.
2222
2323
2424Motivation
@@ -29,7 +29,7 @@ widespread adoption. A challenge with fully-annotated code is that many
2929more imports are required in order to bring the relevant name into scope,
3030potentially causing import cycles without careful design. This has been
3131recognized by :pep: `563 ` and later :pep: `649 `, which introduce two different
32- mechanisms for deferred evaluation of type annotations. As :pep: ` 563 ` notes,
32+ mechanisms for deferred evaluation of type annotations. As PEP 563 notes,
3333"type hints are ... not computationally free". The :data: `typing.TYPE_CHECKING `
3434constant was thus introduced __, initially to aid in breaking cyclic imports.
3535
@@ -75,13 +75,13 @@ Since ``TYPE_CHECKING`` doesn't prohibit assignment, existing code using
7575
7676.. code-block :: python
7777
78- # These code will work as before
78+ # This code will continue to work
7979 TYPE_CHECKING = False
8080 from typing import TYPE_CHECKING
8181
8282
83- User can remove the assingment to ``TYPE_CHECKING `` after they stop using
84- Python before 3.14 .
83+ User can remove the assignment to ``TYPE_CHECKING `` after they stop using
84+ Python 3.13 or older versions .
8585
8686
8787How to Teach This
@@ -90,7 +90,7 @@ How to Teach This
9090* Use ``if TYPE_CHECKING: `` for skipping type-checking code at runtime.
9191* Use ``from typing import TYPE_CHECKING `` to support Python versions before 3.14.
9292* Workarounds like ``TYPE_CHECKING = False `` or ``if False: # TYPE_CHECKING ``
93- are continued to work, but not recommended.
93+ will continue to work, but are not recommended.
9494
9595
9696Reference Implementation
@@ -102,7 +102,7 @@ Reference Implementation
102102Rejected Ideas
103103==============
104104
105- Eliminate type-checking-only Code
105+ Eliminate type-checking-only code
106106---------------------------------
107107
108108It is considered to add real constant named ``__type_checking__ ``
0 commit comments