From 15f4193b764f85dcab042ab193e984bebf151029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Fri, 8 Apr 2022 21:55:22 +0200 Subject: [PATCH] fix: Actually check for docstrings recursively --- src/griffe/dataclasses.py | 2 +- tests/test_dataclasses.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) 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 +