How can I prevent Sphinx from listing "object" as a base class?

Viewed 2396

I have this class:

class Class:
    pass

The documentation generated by sphinx (in case it matters, I used the autodoc extension) looks like this:

class package.Class

     Bases: object

The inheritance from object isn't useful information for the reader, and therefore I don't want it in my documentation. The output I'd like to see is this:

class package.Class


Is there a way to exclude object from the list of base classes?

3 Answers

As for Jun 2022 and Sphinx v5.0.1, Aran-Fey's answer is a bit outdated; the solution that worked in my case was replace this line:

line_to_delete = _(u'Bases: %s') % u':class:`object`'

with this:

line_to_delete = _(u'Bases: %s') % u':py:class:`object`'
Related