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

Overridden, overloaded class docstring return type rendered as None #10280

Closed
laurensvalk opened this issue Mar 21, 2022 · 2 comments
Closed

Comments

@laurensvalk
Copy link

laurensvalk commented Mar 21, 2022

Describe the bug

Some overloaded class definitions show None as a return type, when there shouldn't be any return type.

This seems to happen when the overloaded functions are overridden in the final docstring.

A class without this problem is also provided for comparison.

How to Reproduce

Exactly the same as #10278

Expected behavior

image

Your project

https://github.com/pybricks/sphinx-issues-minimal

Screenshots

image

OS

Ubuntu

Python version

3.8.3

Sphinx version

4.4.0

Sphinx extensions

'sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx_rtd_theme'

Extra tools

No response

Additional context

Related Sphinx issue: #10281

This was originally reported in pybricks/pybricks-api#87

@tk0miya
Copy link
Member

tk0miya commented Apr 2, 2022

This is not related to overloaded constructors. Autodoc automatically fills return value annotation to the signature definitions in the docstring excluding the first entry unexpectedly. So I reproduced this with this class:

class Foo:
    """Foo()
    Foo(x: int)
    Foo(x: int, y: int)

    docstring
    """

I agree this is not unexpected behavior. So I'll fix this soon.

Note: The example you given uses autoclass_content = 'both' option. Then autodoc refers the docstring of MyComplex.__init__() method too.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Apr 2, 2022
…return typehint

Basically, autodoc suppresses return value typehint for class
constructors.  But it was unexpectedly shown if
`autodoc_docstring_signature` is enabled and docstring has multiple
signatures.
@laurensvalk
Copy link
Author

9f52d7d fixes it. Thanks!

image

tk0miya added a commit to tk0miya/sphinx that referenced this issue Apr 2, 2022
…return typehint

Basically, autodoc suppresses return value typehint for class
constructors.  But it was unexpectedly shown if
`autodoc_docstring_signature` is enabled and docstring has multiple
signatures.
@tk0miya tk0miya closed this as completed in a78c07c Apr 3, 2022
tk0miya added a commit that referenced this issue Apr 3, 2022
…trings

Fix #10280: autodoc_docstring_signature generates needless return typehint
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 4, 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