Fix serializing optional Collection attributes#916
Merged
Conversation
Codecov ReportBase: 94.34% // Head: 94.37% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #916 +/- ##
==========================================
+ Coverage 94.34% 94.37% +0.02%
==========================================
Files 83 83
Lines 11989 12015 +26
Branches 1134 1136 +2
==========================================
+ Hits 11311 11339 +28
Misses 496 496
+ Partials 182 180 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
philvarner
approved these changes
Nov 15, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
The underlying problem is that, when creating a Collection from a dict, some values are pulled out to Collection-level attributes, e.g.
pystac/pystac/collection.py
Lines 644 to 646 in 114b1a1
However, those values are not removed from the original dictionary
d, and that original dictionary is used to populateextra_fields:pystac/pystac/collection.py
Line 657 in 114b1a1
This means that the
assetsattribute of a Collection isn't the only place where assets (and other attributes) are stored, and in fact when a collection is turned back into a dictionary, those assets are re-populated fromextra_fields:pystac/pystac/catalog.py
Lines 516 to 517 in 114b1a1
This fixes the issue by popping these optional attributes out of the source dictionary, and by checking for these attributes' presence in a better way (i.e. before we were checking if lists were not None 😞).
PR Checklist:
pre-commit run --all-files)scripts/test)