From 412a44c24298e81c3ee03fcd2b9f847fe608dd33 Mon Sep 17 00:00:00 2001 From: Pranav Choudhary Date: Sat, 24 Oct 2026 01:22:32 +0530 Subject: [PATCH] gh-153528: Document `mode="func_type"` in `compile()` (GH-153561) (cherry picked from commit 02c5d552fc3c020d01149168c1128e47d09a9626) Co-authored-by: Pranav Choudhary --- Doc/builtins/functions.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/builtins/functions.rst b/Doc/builtins/functions.rst index 3951e716a5a0ffd..221e560adc80997 100644 --- a/Doc/builtins/functions.rst +++ b/Doc/builtins/functions.rst @@ -310,6 +310,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 ` should be activated @@ -379,6 +383,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*.