While looking at packagedb/package_managers.py, I noticed that VersionAPI.get_until() builds VersionResponse.valid_versions and newer_versions using sets.
That means duplicates are removed, but the original version order from fetch() is also lost.
There is already a related note in the file:
# FIXME: DO NOT use set() for storing version lists: they lose the original ordering
I think this should preserve fetch order while still deduplicating values.
A possible fix would be:
- change
valid_versions and newer_versions to ordered lists
- keep a small
seen set internally in get_until() for deduplication
- add/update tests in
packagedb/tests/test_package_managers.py
While looking at
packagedb/package_managers.py, I noticed thatVersionAPI.get_until()buildsVersionResponse.valid_versionsandnewer_versionsusing sets.That means duplicates are removed, but the original version order from
fetch()is also lost.There is already a related note in the file:
# FIXME: DO NOT use set() for storing version lists: they lose the original orderingI think this should preserve fetch order while still deduplicating values.
A possible fix would be:
valid_versionsandnewer_versionsto ordered listsseenset internally inget_until()for deduplicationpackagedb/tests/test_package_managers.py