Skip to content

Commit 02c5d55

Browse files
gh-153528: Document mode="func_type" in compile() (#153561)
1 parent dc78afe commit 02c5d55

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
@@ -354,6 +354,10 @@ are always available. They are listed here in alphabetical order.
354354
consists of a single expression, or ``'single'`` if it consists of a single
355355
interactive statement (in the latter case, expression statements that
356356
evaluate to something other than ``None`` will be printed).
357+
It can also be ``'func_type'`` if *source* consists of a
358+
function type signature, for example ``(int) -> str``; see
359+
:func:`ast.parse` for more information. This mode requires passing
360+
:data:`ast.PyCF_ONLY_AST` in *flags*.
357361

358362
The optional arguments *flags* and *dont_inherit* control which
359363
:ref:`compiler options <ast-compiler-flags>` should be activated
@@ -427,6 +431,9 @@ are always available. They are listed here in alphabetical order.
427431
``ast.PyCF_ALLOW_TOP_LEVEL_AWAIT`` can now be passed in flags to enable
428432
support for top-level ``await``, ``async for``, and ``async with``.
429433

434+
.. versionchanged:: 3.8
435+
Added support for ``mode='func_type'``.
436+
430437
.. versionchanged:: 3.12
431438
:exc:`SyntaxError` is raised instead of :exc:`ValueError` when null bytes
432439
are encountered in *source*.

0 commit comments

Comments
 (0)