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

autodoc_preserve_defaults doesn't work on class methods #10421

Closed
Yoshanuikabundi opened this issue May 4, 2022 · 0 comments
Closed

autodoc_preserve_defaults doesn't work on class methods #10421

Yoshanuikabundi opened this issue May 4, 2022 · 0 comments

Comments

@Yoshanuikabundi
Copy link
Contributor

Describe the bug

Default values for class methods are rendered as their __repr__, even with autodoc_preserve_defaults = True in conf.py.

How to Reproduce

Extract the attached example and run make html. Note that the default value for the argument of the regular and static methods render correctly as SOME_DEFAULT, but the default value for the class method renders as its repr.

classmethod_defaults_mre.zip

Expected behavior

All three methods' argument's default values should render as SOME_DEFAULT

Your project

https://github.com/sphinx-doc/sphinx/files/8620112/classmethod_defaults_mre.zip

Screenshots

Screenshot of the rendered attached example demonstrating incorrect rendering:

Screenshot of the rendered attached example demonstrating incorrect rendering

OS

Arch Linux

Python version

3.10.0

Sphinx version

Tested on 4.5 and current 5.x branch (commit 335bf51)

Sphinx extensions

sphinx.ext.autodoc

Extra tools

No response

Additional context

No response

tk0miya added a commit to tk0miya/sphinx that referenced this issue May 7, 2022
tk0miya added a commit to tk0miya/sphinx that referenced this issue May 7, 2022
@tk0miya tk0miya added this to the 5.0.0 milestone May 7, 2022
tk0miya added a commit to tk0miya/sphinx that referenced this issue May 7, 2022
tk0miya added a commit to tk0miya/sphinx that referenced this issue May 8, 2022
@tk0miya tk0miya closed this as completed in 10dd5a0 May 8, 2022
tk0miya added a commit that referenced this issue May 8, 2022
…s_for_classmethod

Fix #10421: autodoc_preserve_defaults doesn't work on class methods
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants