diff --git a/src/griffe/dataclasses.py b/src/griffe/dataclasses.py index 105fb557..a89f827d 100644 --- a/src/griffe/dataclasses.py +++ b/src/griffe/dataclasses.py @@ -353,7 +353,7 @@ def has_docstrings(self) -> bool: if self.has_docstring: # noqa: DAR201 return True for member in self.members.values(): - if (not member.is_alias or member.resolved) and member.has_docstring: # type: ignore[union-attr] + if (not member.is_alias or member.resolved) and member.has_docstrings: # type: ignore[union-attr] return True return False diff --git a/tests/test_dataclasses.py b/tests/test_dataclasses.py index a55269d5..d28b3f7a 100644 --- a/tests/test_dataclasses.py +++ b/tests/test_dataclasses.py @@ -1,7 +1,6 @@ """Tests for the `dataclasses` module.""" - -from griffe.dataclasses import Module +from griffe.dataclasses import Docstring, Module def test_submodule_exports(): @@ -20,3 +19,11 @@ def test_submodule_exports(): root.exports = {"sub"} assert root.member_is_exported(sub, explicitely=True) assert root.member_is_exported(sub, explicitely=False) + + +def test_has_docstrings(): + """Assert the `.has_docstrings` method is recursive.""" + module = module_vtree("a.b.c.d") + module["b.c.d"].docstring = Docstring("Hello.") + assert module.has_docstrings +