diff --git a/Doc/library/constants.rst b/Doc/library/constants.rst index c0ac4ea8412ebd..645ae77b1bb0f8 100644 --- a/Doc/library/constants.rst +++ b/Doc/library/constants.rst @@ -70,6 +70,15 @@ A small number of constants live in the built-in namespace. They are: ``Ellipsis`` is the sole instance of the :data:`types.EllipsisType` type. +.. data:: TYPE_CHECKING + + This constant is same to :data:`typing.TYPE_CHECKING`. + It is always ``False`` at runtime, but third party static type checkers + assumes it to be ``True``. + + .. versionadded:: next + + .. data:: __debug__ This constant is true if Python was not started with an :option:`-O` option. diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 6709f306bb024d..f0422680fa625d 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -3407,6 +3407,7 @@ _PyBuiltin_Init(PyInterpreterState *interp) SETBUILTIN("tuple", &PyTuple_Type); SETBUILTIN("type", &PyType_Type); SETBUILTIN("zip", &PyZip_Type); + SETBUILTIN("TYPE_CHECKING", Py_False); debug = PyBool_FromLong(config->optimization_level == 0); if (PyDict_SetItemString(dict, "__debug__", debug) < 0) { Py_DECREF(debug);