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 request and jsonschema optional dependencies #156

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

vincentsarago
Copy link
Member

Both requests and jsonschema are imported for validation but are not part of the dependencies. This PR adds a validation optional dependencies.

pyproject.toml Outdated Show resolved Hide resolved
# can't use `stac_obj.model_dump()` here
# b/c jsonschema expects pure string representations, not python types
stac_dict = json.loads(stac_obj.model_dump_json())
stac_dict = stac_obj.model_dump(mode="json")
Copy link
Member Author

Choose a reason for hiding this comment

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

use mode="json" instead of model_dump_json + json.loads

stac_item = r.json()
try:
item = Item(**stac_item)
item = Item.model_validate(stac_item)
Copy link
Member Author

Choose a reason for hiding this comment

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

model_validate is the recommended way of parsing/validating an object

@vincentsarago vincentsarago merged commit 92c8a70 into main Jul 9, 2024
5 checks passed
@vincentsarago vincentsarago deleted the feature/add-optional-dependencies branch July 9, 2024 07:32
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