Skip to content

Commit

Permalink
fix: Catch more inspection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Feb 20, 2023
1 parent 91dc74f commit 4f6eef9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/griffe/agents/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ def _should_create_alias(parent: ObjectNode, child: ObjectNode, current_module_p
if isinstance(child_obj, cached_property):
child_obj = child_obj.func

child_module = getmodule(child_obj)
try:
child_module = getmodule(child_obj)
except Exception: # getmodule can trigger exceptions
return None
if not child_module:
return None

Expand Down Expand Up @@ -183,8 +186,11 @@ def __init__(
self.lines_collection: LinesCollection = lines_collection or LinesCollection()

def _get_docstring(self, node: ObjectNode) -> Docstring | None:
# access `__doc__` directly to avoid taking the `__doc__` attribute from a parent class
value = getattr(node.obj, "__doc__", None)
try:
# access `__doc__` directly to avoid taking the `__doc__` attribute from a parent class
value = getattr(node.obj, "__doc__", None)
except Exception: # getattr can trigger exceptions
return None
if value is None:
return None
try:
Expand Down

0 comments on commit 4f6eef9

Please sign in to comment.