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

Fix: Do not set deleted items to UserList._items in UserList.remove_items() #30

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

glensc
Copy link
Owner

@glensc glensc commented Apr 18, 2023

Seems like a bug. Does not make sense to set _items to the value of deleted items.

Git blame points to 51b1b7b commit:

51b1b7b0 (moogar0880      2015-02-14 22:05:10 -0500 178)         self._items = items
51b1b7b0 (moogar0880      2015-02-14 22:05:10 -0500 205)         self._items = items

Seems to me the code is copy-paste from def add_items(self, *items)

@glensc glensc requested a review from simonc56 April 18, 2023 20:37
@glensc glensc self-assigned this Apr 18, 2023
@simonc56
Copy link
Collaborator

Also in def add_items(self, *items) it doesn't make sense to set _items to the value of added items. What about items already in list ?

@glensc glensc changed the title Fix: Do not set deleted items to UserList._items Fix: Do not set deleted items to UserList._items in UserList.remove_items() Apr 19, 2023
@glensc
Copy link
Owner Author

glensc commented Apr 19, 2023

And get_items appends to the list, if called multiple times with different list value the result would be pointless, i.e it's collection of random things, not a definition of a UserList.

I think get_items was not intended to be used outside the class and it should just return the data rather updating self._items.
the self._items update could be moved to _get.

and addition to that add_items should merge the _items, and remove_items should remove items from _items.

the _items is used for the iter outside the class.

@glensc glensc marked this pull request as draft August 30, 2023 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants