Skip to content

Commit

Permalink
Better approach
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Mar 19, 2021
1 parent 30853b4 commit fe7a870
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion assertpy/extracting.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
__tracebackhide__ = True


try:
from pydantic import BaseModel as PydanticBase
except ImportError:
class PydanticBase:
pass # implement necessary parts here


class ExtractingMixin(object):
"""Collection flattening mixin.
Expand Down Expand Up @@ -177,7 +184,7 @@ def _extract(x, name):
return x[name]
else:
raise ValueError('item keys %s did not contain key <%s>' % (list(x.keys()), name))
elif isinstance(x, Iterable):
elif isinstance(x, Iterable) and not isinstance(x, PydanticBase):
self._check_iterable(x, name='item')
return x[name]
elif hasattr(x, name):
Expand Down

0 comments on commit fe7a870

Please sign in to comment.