Skip to content

Commit

Permalink
Add AttrList.to_list() (#1584)
Browse files Browse the repository at this point in the history
* Add AttrList.to_list()

* simplify to_list() implementation

* code formatting

---------

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
  • Loading branch information
kujiy and miguelgrinberg committed Apr 24, 2024
1 parent f4f6f13 commit b059c0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions elasticsearch_dsl/utils.py
Expand Up @@ -101,6 +101,9 @@ def __getstate__(self):
def __setstate__(self, state):
self._l_, self._obj_wrapper = state

def to_list(self):
return self._l_


class AttrDict:
"""
Expand Down
6 changes: 6 additions & 0 deletions tests/test_utils.py
Expand Up @@ -100,3 +100,9 @@ def test_recursive_to_dict():
assert utils.recursive_to_dict({"k": [1, (1.0, {"v": Q("match", key="val")})]}) == {
"k": [1, (1.0, {"v": {"match": {"key": "val"}}})]
}


def test_attrlist_to_list():
l = utils.AttrList([{}, {}]).to_list()
assert isinstance(l, list)
assert l == [{}, {}]

0 comments on commit b059c0a

Please sign in to comment.