Skip to content

Commit

Permalink
fix: Don't crash on attribute error when trying to detect field
Browse files Browse the repository at this point in the history
Issue-149: #149
  • Loading branch information
pawamoy committed Nov 26, 2024
1 parent 8131235 commit cd9407f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pytkdocs/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import inspect
import pkgutil
import re
from contextlib import suppress
from functools import lru_cache
from itertools import chain
from operator import attrgetter
Expand Down Expand Up @@ -554,8 +555,9 @@ def detect_field_model(self, attr_name: str, direct_members: Sequence[str], all_
):
return False

if remainder and not attrgetter(remainder)(all_members[first_order_attr_name]): # noqa: SIM103
return False
if remainder:
with suppress(AttributeError):
return bool(attrgetter(remainder)(all_members[first_order_attr_name]))
return True

def add_fields(
Expand Down

0 comments on commit cd9407f

Please sign in to comment.