Skip to content

Commit f47b4bb

Browse files
kujiymiguelgrinberg
authored andcommitted
Add AttrList.to_list()
1 parent f4f6f13 commit f47b4bb

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

elasticsearch_dsl/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def __getstate__(self):
101101
def __setstate__(self, state):
102102
self._l_, self._obj_wrapper = state
103103

104+
def to_list(self):
105+
return [x for x in self.__iter__()]
104106

105107
class AttrDict:
106108
"""

tests/test_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,8 @@ def test_recursive_to_dict():
100100
assert utils.recursive_to_dict({"k": [1, (1.0, {"v": Q("match", key="val")})]}) == {
101101
"k": [1, (1.0, {"v": {"match": {"key": "val"}}})]
102102
}
103+
104+
def test_attrlist_to_list():
105+
l = utils.AttrList([{}, {}]).to_list()
106+
assert isinstance(l, list)
107+
assert l == [{}, {}]

0 commit comments

Comments
 (0)