@@ -2,12 +2,12 @@ PEP: 781
22Title: Adding __type_checking__ constant
33Author: Inada Naoki <songofacandy@gmail.com>
44Discussions-To: https://discuss.python.org/t/85728
5- Post-History: 11-Jan-2025 https://discuss.python.org/t/76766
65Status: Draft
76Type: Standards Track
87Topic: Typing
98Created: 24-Mar-2025
109Python-Version: 3.14
10+ Post-History: `11-Jan-2025 <https://discuss.python.org/t/76766 >`__
1111
1212
1313Abstract
@@ -66,15 +66,19 @@ a matching pattern.
6666Similar 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
7075How 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
8084Reference Implementation
0 commit comments