-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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: signature of __new__ overwrites signature of __init__ #13257
Comments
The way
Both options are viable and already introduce lots of flexibility, with the first one being especially beginner friendly. You're proposing to use |
I am using I have looked at autodoc-process-signature and it is not immediately clear to me, how to obtain the functionality that I want. Having an easy way of influencing this behavior, e.g., by a I think, having this option especially makes sense, when you say that there is no right way for all users. |
I usually start out by being skeptical of reports in the Sphinx repo but you do have a strong case here.
This kind of extra difficulty in customizing small problems is probably what leads a lot of devs to switch to the more complicated
I had forgotten about this workaround:
If that doesn't work, I'm also not sure if the |
Thank you for the workaround suggestions. I will have a look at them. For the time being I have switched to: autodoc_class_signature = "separated"
Yeah. I can see that. I have thought about that a few time, but this decision is not entirely up to me. I wanted to provide a bit more context. I encountered the issue when creating a derived class from the SciPy LinearOperator class, which is the documented way of implementing the linear operator interface. The LinearOperator defines a |
These kind of inheritance problems are known, you can search the Sphinx repo for previous reports. This isn't exactly a bug since the inheritance and documentation mechanisms are working normally as expected.
This does make a lot of sense, but I'm not an |
Describe the bug
The
__new__
method of a class is expected to accept the same arguments as the__init__
method. Since a__new__
method for a class also has to work for all derived classes, the__new__
method usually has the signature:Nevertheless, when constructing the class, the arguments of the
__init__
method must be provided.When using autodoc with
autodoc_class_signature = 'mixed'
for a class with an__init__
and a__new__
method, the signature of the__new__
method is show in the class signature. However, I would expect that the function signature of__init__
is shown.How to Reproduce
An MWE repository is provided here: hrittich/sphinx-signature-bug-mwe.
conf.py
index.rst
mwe_package.py
Renders the documentation as
instead of
Environment Information
Sphinx extensions
Additional context
No response
The text was updated successfully, but these errors were encountered: