Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AttrList.to_list() #1584

Merged
merged 3 commits into from
Apr 24, 2024
Merged

Add AttrList.to_list() #1584

merged 3 commits into from
Apr 24, 2024

Conversation

kujiy
Copy link
Contributor

@kujiy kujiy commented Apr 27, 2022

AttrDict has to_dict() but AttrList does not have to_list().

AttrList does not work for PyDantic as a data type. It's good if anyone can convert AttrList to list easily.

Thanks,

@cla-checker-service
Copy link

cla-checker-service bot commented Apr 27, 2022

💚 CLA has been signed

@kujiy
Copy link
Contributor Author

kujiy commented Apr 27, 2022

I signed the CLA. Please proceed the review, thanks

@@ -101,6 +101,8 @@ def __getstate__(self):
def __setstate__(self, state):
self._l_, self._obj_wrapper = state

def to_list(self):
return [x for x in self.__iter__()]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest doing it analogically with AttrDict.

This will get the original value.

def to_list(self):
    return self._l_

@miguelgrinberg miguelgrinberg merged commit b059c0a into elastic:main Apr 24, 2024
15 checks passed
@miguelgrinberg miguelgrinberg added the backport 8.x Backport to 8.x label Apr 29, 2024
github-actions bot pushed a commit that referenced this pull request Apr 29, 2024
* Add AttrList.to_list()

* simplify to_list() implementation

* code formatting

---------

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
(cherry picked from commit b059c0a)
miguelgrinberg pushed a commit that referenced this pull request Apr 29, 2024
* Add AttrList.to_list()

* simplify to_list() implementation

* code formatting

---------

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
(cherry picked from commit b059c0a)
miguelgrinberg pushed a commit that referenced this pull request Apr 29, 2024
* Add AttrList.to_list()

* simplify to_list() implementation

* code formatting

---------

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
(cherry picked from commit b059c0a)

Co-authored-by: Kujiy <kujiy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 8.x Backport to 8.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants