Skip to content

Commit a942926

Browse files
committed
update based on the feedback from the discussion
1 parent 1651246 commit a942926

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

peps/pep-0781.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ PEP: 781
22
Title: Adding __type_checking__ constant
33
Author: Inada Naoki <songofacandy@gmail.com>
44
Discussions-To: https://discuss.python.org/t/85728
5-
Post-History: 11-Jan-2025 https://discuss.python.org/t/76766
65
Status: Draft
76
Type: Standards Track
87
Topic: Typing
98
Created: 24-Mar-2025
109
Python-Version: 3.14
10+
Post-History: `11-Jan-2025 <https://discuss.python.org/t/76766>`__
1111

1212

1313
Abstract
@@ -66,15 +66,19 @@ a matching pattern.
6666
Similar to :data:`typing.TYPE_CHECKING`, type checking tools should treat
6767
``__type_checking__`` as ``True``.
6868

69+
Once this PEP is accepted, ``__type_checking__`` will be the preferred way over
70+
``typing.TYPE_CHECKING``. However, ``typing.TYPE_CHECKING`` will not be deprecated.
71+
Instead, it will be implemented using ``__type_checking__``, allowing future type
72+
checkers to focus on handling ``__type_checking__`` only.
73+
6974

7075
How to Teach This
7176
=================
7277

73-
Add this note to the ``typing.TYPE_CHECKING`` document:
74-
75-
> If you don't want to import ``typing``, you can use ``__type_checking__``.
76-
> Workarounds like ``TYPE_CHECKING = False`` or
77-
> ``if False: # TYPE_CHECKING`` are not recommended since Python 3.14.
78+
* Use ``__type_checking__`` for skipping type-checking code at runtime.
79+
* Use :data:`typing.TYPE_CHECKING` to support Python versions before 3.14.
80+
* Workarounds like ``TYPE_CHECKING = False`` or ``if False: # TYPE_CHECKING``
81+
are not recommended since Python 3.14.
7882

7983

8084
Reference Implementation

0 commit comments

Comments
 (0)