Fixes incorrectly handled type error when list of objects is found in data (#12593)

* fixes incorrectly handled type error when list of objects is found in data #9876

* fixes incorrectly handled type error when list of objects is found in data #9876

* fixes incorrectly handled type error when list of objects is found in data #9876
This commit is contained in:
Abhimanyu Saharan 2023-06-01 01:14:59 +05:30 committed by GitHub
parent 1349a25e34
commit e7f689bc52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,8 +65,14 @@ class Condition:
"""
Evaluate the provided data to determine whether it matches the condition.
"""
def _get(obj, key):
if isinstance(obj, list):
return [dict.get(i, key) for i in obj]
return dict.get(obj, key)
try:
value = functools.reduce(dict.get, self.attr.split('.'), data)
value = functools.reduce(_get, self.attr.split('.'), data)
except TypeError:
# Invalid key path
value = None