@@ -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 *.
@@ -765,7 +772,7 @@ are always available. They are listed here in alphabetical order.
765772 still access all builtins.
766773
767774 The *closure * argument specifies a closure--a tuple of cellvars.
768- It's only valid when the * object * is a code object containing
775+ It's only valid when * source * is a code object containing
769776 :term: `free (closure) variables <closure variable> `.
770777 The length of the tuple must exactly match the length of the code object's
771778 :attr: `~codeobject.co_freevars ` attribute.
@@ -1846,8 +1853,6 @@ are always available. They are listed here in alphabetical order.
18461853 including the name and address of the object. A class can control what this
18471854 function returns for its instances
18481855 by defining a :meth: `~object.__repr__ ` method.
1849- If :func: `sys.displayhook ` is not accessible, this function will raise
1850- :exc: `RuntimeError `.
18511856
18521857 This class has a custom representation that can be evaluated::
18531858
@@ -2161,10 +2166,10 @@ are always available. They are listed here in alphabetical order.
21612166
21622167 When called directly within an ordinary method of a class, both arguments may
21632168 be omitted ("zero-argument :func: `!super `"). In this case, *type * will be the
2164- enclosing class, and *obj * will be the first argument of the immediately
2165- enclosing function (typically ``self ``). (This means that zero -argument
2169+ enclosing class, and *object_or_type * will be the first argument of the
2170+ immediately enclosing function (typically ``self ``). Zero -argument
21662171 :func: `!super ` will not work as expected within nested functions, including
2167- generator expressions, which implicitly create nested functions.)
2172+ generator expressions, which implicitly create nested functions.
21682173
21692174 There are two typical use cases for *super *. In a class hierarchy with
21702175 single inheritance, *super * can be used to refer to parent classes without
@@ -2423,10 +2428,9 @@ are always available. They are listed here in alphabetical order.
24232428 determine the package context of the :keyword: `import ` statement.
24242429
24252430 *level * specifies whether to use absolute or relative imports. ``0 `` (the
2426- default) means only perform absolute imports. Positive values for
2427- *level * indicate the number of parent directories to search relative to the
2428- directory of the module calling :func: `__import__ ` (see :pep: `328 ` for the
2429- details).
2431+ default) means only perform absolute imports. For relative imports,
2432+ ``1 `` refers to the current package, ``2 `` to its parent package, and so on
2433+ (see :pep: `328 ` for details).
24302434
24312435 When the *name * variable is of the form ``package.module ``, normally, the
24322436 top-level package (the name up till the first dot) is returned, *not * the
0 commit comments