Skip to content

Commit cd9407f

Browse files
committed
fix: Don't crash on attribute error when trying to detect field
Issue-149: #149
1 parent 8131235 commit cd9407f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/pytkdocs/loader.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import inspect
99
import pkgutil
1010
import re
11+
from contextlib import suppress
1112
from functools import lru_cache
1213
from itertools import chain
1314
from operator import attrgetter
@@ -554,8 +555,9 @@ def detect_field_model(self, attr_name: str, direct_members: Sequence[str], all_
554555
):
555556
return False
556557

557-
if remainder and not attrgetter(remainder)(all_members[first_order_attr_name]): # noqa: SIM103
558-
return False
558+
if remainder:
559+
with suppress(AttributeError):
560+
return bool(attrgetter(remainder)(all_members[first_order_attr_name]))
559561
return True
560562

561563
def add_fields(

0 commit comments

Comments
 (0)