Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Aug 3, 2023

Fix #11543.
Fix #11459.

@picnixz
Copy link
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
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
CHANGES Outdated Show resolved Hide resolved
@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
Member

Thanks!

@AA-Turner AA-Turner merged commit 76658c4 into sphinx-doc:master Aug 17, 2023
27 checks passed
@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
2 participants