https://github.com/python/cpython/commit/02c5d552fc3c020d01149168c1128e47d09a9626
commit: 02c5d552fc3c020d01149168c1128e47d09a9626
branch: main
author: Pranav Choudhary <[email protected]>
committer: JelleZijlstra <[email protected]>
date: 2026-10-23T19:52:32Z
summary:
gh-153528: Document `mode="func_type"` in `compile()` (#153561)
files:
M Doc/builtins/functions.rst
diff --git a/Doc/builtins/functions.rst b/Doc/builtins/functions.rst
index f6203b026d32a4f..e97fd8293b6a716 100644
--- a/Doc/builtins/functions.rst
+++ b/Doc/builtins/functions.rst
@@ -354,6 +354,10 @@ are always available. They are listed here in
alphabetical order.
consists of a single expression, or ``'single'`` if it consists of a single
interactive statement (in the latter case, expression statements that
evaluate to something other than ``None`` will be printed).
+ It can also be ``'func_type'`` if *source* consists of a
+ function type signature, for example ``(int) -> str``; see
+ :func:`ast.parse` for more information. This mode requires passing
+ :data:`ast.PyCF_ONLY_AST` in *flags*.
The optional arguments *flags* and *dont_inherit* control which
:ref:`compiler options <ast-compiler-flags>` should be activated
@@ -427,6 +431,9 @@ are always available. They are listed here in alphabetical
order.
``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable
support for top-level ``await``, ``async for``, and ``async with``.
+ .. versionchanged:: 3.8
+ Added support for ``mode='func_type'``.
+
.. versionchanged:: 3.12
:exc:`SyntaxError` is raised instead of :exc:`ValueError` when null bytes
are encountered in *source*.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]