Skip to content

:inherited-members: Excludes All Members from Base Classes Appearing After the Excluded Class in Multiple Inheritance #13316

Open
@GaryFrewin

Description

@GaryFrewin

Describe the bug

Description:
When documenting a class with multiple inheritance using sphinx.ext.autodoc, the :inherited-members: directive does not behave as expected. Specifically, if you exclude inherited members from one base class, Sphinx incorrectly excludes all members from base classes that appear after the excluded one in the inheritance hierarchy.

How to Reproduce

class MixinA:
    def method_a(self):
        """Method from MixinA."""

class MixinB:
    def method_b(self):
        """Method from MixinB."""

class MixinC:
    def method_c(self):
        """Method from MixinC."""

class MyClass(MixinA, MixinB, MixinC):
    def my_method(self):
        """Method from MyClass."""

Sphinx .rst Configuration:

.. autoclass:: MyClass
   :members:
   :inherited-members: MixinB

This results in a output doc that ALSO exclude members from MixinC.

Environment Information

Please paste all output below into the bug report template



Platform:              linux; (Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.35)
Python version:        3.11.2 (main, Oct  4 2024, 09:08:31) [GCC 11.3.0])
Python implementation: CPython
Sphinx version:        8.1.3
Docutils version:      0.21.2
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions