Skip to content

Fix sphinx.ext.autodoc.preserve_defaults extension.#11550

Merged
AA-Turner merged 30 commits intosphinx-doc:masterfrom
picnixz:fix/11543-patch-update-default-values
Aug 17, 2023
Merged

Fix sphinx.ext.autodoc.preserve_defaults extension.#11550
AA-Turner merged 30 commits intosphinx-doc:masterfrom
picnixz:fix/11543-patch-update-default-values

Conversation

@picnixz
Copy link
Copy Markdown
Member

@picnixz picnixz commented Aug 3, 2023

Fix #11543.
Fix #11459.

@picnixz
Copy link
Copy Markdown
Member Author

picnixz commented Aug 3, 2023

I said that it would "fix" but it's not entirely true because it's unforunately impossible to recover the raw (non-evaluated) default value of a dataclass with the default __init__ method. In order to recover the default arguments, we need the whole context (possibly imported) because the __init__ method is generated dynamically in dataclasses, so recovering the raw default values will be too complex. I'll add some documentation note in the PR fixing #11459.

- Add support for ``async def`` functions.
- Add support for ``lambda`` functions.
- Rename ``get_function_def`` to ``get_arguments`` and update its
  signature accordingly. Previously, ``get_function_def`` incorrectly
  extracted ``ast.FunctionDef`` from an arbitrary object.
- Silently suppress syntax errors arising from multi-line parsing.
@picnixz
Copy link
Copy Markdown
Member Author

picnixz commented Aug 3, 2023

It was stupid of me to split the task into two since I would end up updating the comment. So let's fix the extension in one go.

@picnixz picnixz force-pushed the fix/11543-patch-update-default-values branch from 6e09f0e to a3442ae Compare August 3, 2023 12:00
@picnixz picnixz force-pushed the fix/11543-patch-update-default-values branch from a3442ae to 36d6593 Compare August 3, 2023 12:02
@AA-Turner AA-Turner mentioned this pull request Aug 16, 2023
@AA-Turner AA-Turner added this to the 7.2.0 milestone Aug 16, 2023
@AA-Turner AA-Turner enabled auto-merge (squash) August 17, 2023 00:27
@AA-Turner
Copy link
Copy Markdown
Member

Thanks!

@AA-Turner AA-Turner merged commit 76658c4 into sphinx-doc:master Aug 17, 2023
@picnixz picnixz deleted the fix/11543-patch-update-default-values branch August 17, 2023 07:27
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handler autodoc throw exceptions after >= 7.1.0 release autodoc preserve defaults leads to exception on multiline lambda

2 participants