From ed5a5f03ded62aaad75537c318860dc16a9b73bb Mon Sep 17 00:00:00 2001 From: pranavchoudhary-tech Date: Tue, 13 Oct 2026 11:42:32 +0530 Subject: [PATCH 1/2] gh-153528: Document `mode="func_type"` in `compile()` --- Doc/builtins/functions.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/builtins/functions.rst b/Doc/builtins/functions.rst index ece666030db9814..4c12ee5d852f462 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 :pep:`484` + 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 @@ -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*. From 0ded217eca66b5ef2787f9c67d69b5d28de802d5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 23 Oct 2026 12:45:58 -0700 Subject: [PATCH 2/2] Apply suggestion from @JelleZijlstra --- Doc/builtins/functions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/builtins/functions.rst b/Doc/builtins/functions.rst index 4c12ee5d852f462..73b74430c3d501e 100644 --- a/Doc/builtins/functions.rst +++ b/Doc/builtins/functions.rst @@ -354,7 +354,7 @@ 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 :pep:`484` + 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*.