You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using functools.singledispatchmethod together with classmethod, no :classmethod: directive option is added by sphinx.ext.autodoc.MethodDocumenter.
Using the example below, the reST directive result is
.. py:class:: MyClass():module: class
My class.
.. py:method:: MyClass.dispatch(x):module: class
A singledispatch class method.
.. py:method:: MyClass.method():module: class
:classmethod:
A class method.
The inspection of a classmethod when the latter is wrapped in a singledispatchmethod does not detect it as a classmethod. In particular, I would suggest replacing this test by the following line:
ifinspect.isclassmethod(obj) or (
inspect.is_singledispatch_method(obj)
andinspect.isclassmethod(obj.func)
):
...
How to Reproduce
class.py
fromfunctoolsimportsingledispatchmethodclassMyClass:
"""My class."""@singledispatchmethod@classmethoddefdispatch(cls, x):
"""A singledispatch class method."""return0@classmethoddefmethod(cls):
"""A class method."""pass
Describe the bug
When using functools.singledispatchmethod together with
classmethod
, no:classmethod:
directive option is added bysphinx.ext.autodoc.MethodDocumenter
.Using the example below, the reST directive result is
The issue lies in the following line:
sphinx/sphinx/ext/autodoc/__init__.py
Lines 2171 to 2172 in 669bcc0
The inspection of a classmethod when the latter is wrapped in a
singledispatchmethod
does not detect it as a classmethod. In particular, I would suggest replacing this test by the following line:How to Reproduce
class.py
index.rst
conf.py
Environment Information
Sphinx extensions
['sphinx.ext.autodoc']
Additional context
The same issue seems to happen with
staticmethod
: #10529 (comment)The text was updated successfully, but these errors were encountered: