Skip to content

Commit e561b19

Browse files
[3.15] gh-153528: Document mode="func_type" in compile() (GH-153561) (#160479)
(cherry picked from commit 02c5d55) Co-authored-by: Pranav Choudhary <pranav.nstblr@gmail.com>
1 parent d6903b5 commit e561b19

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎Doc/builtins/functions.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ are always available. They are listed here in alphabetical order.
314314
consists of a single expression, or ``'single'`` if it consists of a single
315315
interactive statement (in the latter case, expression statements that
316316
evaluate to something other than ``None`` will be printed).
317+
It can also be ``'func_type'`` if *source* consists of a
318+
function type signature, for example ``(int) -> str``; see
319+
:func:`ast.parse` for more information. This mode requires passing
320+
:data:`ast.PyCF_ONLY_AST` in *flags*.
317321

318322
The optional arguments *flags* and *dont_inherit* control which
319323
:ref:`compiler options <ast-compiler-flags>` should be activated
@@ -387,6 +391,9 @@ are always available. They are listed here in alphabetical order.
387391
``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable
388392
support for top-level ``await``, ``async for``, and ``async with``.
389393

394+
.. versionchanged:: 3.8
395+
Added support for ``mode='func_type'``.
396+
390397
.. versionchanged:: 3.12
391398
:exc:`SyntaxError` is raised instead of :exc:`ValueError` when null bytes
392399
are encountered in *source*.

0 commit comments

Comments
 (0)