0

I'd like to document an attribute of a module which holds a callable, more specifically a type. This attribute is intended to store some type, not be an alias of the type.

When I document the attribute, Sphinx renders the call signature of the type associated with it by default.

Example 1

I'd like it to simply show the type.

Example 2

So I did some digging and created this MWE. It seems that it boils down to two factors: using autodoc-typehints and having a parameter with a type hint in the class constructor. Taking either one out produces the correct form above.

# package.py
class Foo:
    def __init__(self, baz: int):
        pass

bar_type = Foo

# documentation
.. currentmodule:: package
.. autoclass:: Foo
.. autodata:: bar_type

# Sphinx conf.py
extensions = [
    'sphinx.ext.autodoc',
    'sphinx_autodoc_typehints',
]

I'm using autodoc-typehints because of other reasons, so I'd be hard-pressed to get rid of it. How could I avoid showing the signature in bar_type?

Felix
  • 2,548
  • 19
  • 48

0 Answers0