Skip to content

Docstrings are not inherited #96

@davfsa

Description

@davfsa

Describe the bug
Docstrings are not inherited. Considering this is not any special case and it defined by the Python standard, I thought it would be appropriate to open the issue here, but the end goal is for mkdocstrings.

To Reproduce
Steps to reproduce the behavior:

class A:
    def foo(self):
        """This is a docstring"""

class B(A):
    def foo(self):
        # Inherited docstring defined in A.foo
>>> from griffe.loader import GriffeLoader
>>> loader = GriffeLoader()
>>> module = loader.load_module("module")
>>> print(module.classes["A"].functions["foo"].docstring)
This is a docstring
>>> print(module.classes["B"].functions["foo"].docstring)
None

Expected behavior
Docstrings are inherited.

System:

  • griffe version: 0.22.0
  • Python version: 3.10.4
  • OS: Linux

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions