Skip to content

Commit

Permalink
refactor: Add bool methods to docstrings and objects
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Nov 13, 2021
1 parent 752e084 commit 548f72e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/griffe/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ def __init__(
self.parser: Parser | None = parser
self.parser_options: dict[str, Any] = parser_options or {}

def __bool__(self):
return bool(self.value)

@cached_property
def lines(self) -> list[str]:
"""Returns the lines of the docstring.
Expand Down Expand Up @@ -323,6 +326,9 @@ def __getitem__(self, key):
return self.members[parts[0]]
return self.members[parts[0]][parts[1]]

def __bool__(self):
return bool(self.docstring) or any(self.members.values())

@cached_property
def module(self) -> Module:
"""Return the parent module of this object.
Expand Down

0 comments on commit 548f72e

Please sign in to comment.