Skip to content

Commit

Permalink
fix: Actually check for docstrings recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Apr 8, 2022
1 parent 60669dc commit 15f4193
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/griffe/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 9 additions & 2 deletions tests/test_dataclasses.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Tests for the `dataclasses` module."""


from griffe.dataclasses import Module
from griffe.dataclasses import Docstring, Module


def test_submodule_exports():
Expand All @@ -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

0 comments on commit 15f4193

Please # to comment.