From 36d65931024f90d8e7cca42c8d6c90ec5776d37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:46:18 +0200 Subject: [PATCH] update CHANGES --- CHANGES | 12 ++++++++++++ sphinx/ext/autodoc/preserve_defaults.py | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 645a6cd4c9d..03ed7e55728 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,12 @@ Dependencies Incompatible changes -------------------- +* #11459: ``sphinx.ext.autodoc.preserve_defaults.get_function_def`` is + renamed ``sphinx.ext.autodoc.preserve_defaults.get_arguments`` and its + signature is updated accordingly. It now extracts the ``ast.arguments`` from + a function or a lambda function object. + Patch by Bénédikt Tran. + Deprecated ---------- @@ -36,12 +42,18 @@ Features added Patch by Rouslan Korneychuk. * 10938: doctest: Add :confval:`doctest_show_successes` option. Patch by Trey Hunner. +* #11459: ``sphinx.ext.autodoc.preserve_defaults``: Add support for + ``async def`` functions and lambda functions. + Patch by Bénédikt Tran. Bugs fixed ---------- * #11077: graphviz: Fix relative links from within the graph. Patch by Ralf Grubenmann. +* #11459: ``sphinx.ext.autodoc.preserve_defaults``: fix lambda functions + used inside ``@property`` should be ignored in a multi-line context. + Patch by Bénédikt Tran. * #11529: Line Block in LaTeX builder outputs spurious empty token. Patch by Adrian Vollmer. diff --git a/sphinx/ext/autodoc/preserve_defaults.py b/sphinx/ext/autodoc/preserve_defaults.py index 295c7f9468e..3622aa9fbc5 100644 --- a/sphinx/ext/autodoc/preserve_defaults.py +++ b/sphinx/ext/autodoc/preserve_defaults.py @@ -46,7 +46,7 @@ def get_arguments(obj: Any) -> ast.arguments | None: # subject is placed inside class or block. To read its docstring, # this adds if-block before the declaration. module = ast.parse('if True:\n' + source) - subject = module.body[0].body[0] + subject = module.body[0].body[0] # type: ignore[attr-defined] else: module = ast.parse(source) subject = module.body[0] @@ -67,7 +67,7 @@ def get_arguments(obj: Any) -> ast.arguments | None: # propagated). raise - def _get_arguments(x: ast.AST) -> ast.arguments | None: + def _get_arguments(x: Any) -> ast.arguments | None: if isinstance(x, (ast.AsyncFunctionDef, ast.FunctionDef, ast.Lambda)): return x.args if isinstance(x, (ast.Assign, ast.AnnAssign)):