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

Link.to_dict() should only contain strings #1114

Merged
merged 2 commits into from
May 8, 2023

Conversation

jsignell
Copy link
Member

@jsignell jsignell commented May 4, 2023

Related Issue(s):
I know this issue is closed, but I think this PR does what the OP intended.

Description:

I just encountered this recently when checking how a dict roundtrips. This is what I was doing:

import pystac
import requests

response = requests.get("https://staging-stac.delta-backend.com/collections/no2-monthly-diff")
collection_dict = response.json()
collection_dict["links"]
[{'rel': 'items',
  'type': 'application/geo+json',
  'href': 'https://staging-stac.delta-backend.com/collections/no2-monthly-diff/items'},
 {'rel': 'parent',
  'type': 'application/json',
  'href': 'https://staging-stac.delta-backend.com/'},
 {'rel': 'root',
  'type': 'application/json',
  'href': 'https://staging-stac.delta-backend.com/'},
 {'rel': 'self',
  'type': 'application/json',
  'href': 'https://staging-stac.delta-backend.com/collections/no2-monthly-diff'}]
collection = pystac.Collection.from_dict(collection_dict)
collection.validate()
collection.to_dict()["links"]

Before this PR

[{'rel': 'items',
  'href': 'https://staging-stac.delta-backend.com/collections/no2-monthly-diff/items',
  'type': 'application/geo+json'},
 {'rel': 'parent',
  'href': 'https://staging-stac.delta-backend.com/',
  'type': 'application/json'},
 {'rel': <RelType.ROOT: 'root'>,
  'href': 'https://staging-stac.delta-backend.com/',
  'type': <MediaType.JSON: 'application/json'>,
  'title': 'veda-stac'},
 {'rel': 'self',
  'href': 'https://staging-stac.delta-backend.com/collections/no2-monthly-diff',
  'type': 'application/json'}]

After this PR

[{'rel': 'items',
  'href': 'https://staging-stac.delta-backend.com/collections/no2-monthly-diff/items',
  'type': 'application/geo+json'},
 {'rel': 'parent',
  'href': 'https://staging-stac.delta-backend.com/',
  'type': 'application/json'},
 {'rel': 'root',
  'href': 'https://staging-stac.delta-backend.com/',
  'type': 'application/json',
  'title': 'veda-stac'},
 {'rel': 'self',
  'href': 'https://staging-stac.delta-backend.com/collections/no2-monthly-diff',
  'type': 'application/json'}]

PR Checklist:

  • pre-commit hooks pass locally
  • Tests pass (run scripts/test)
  • Documentation has been updated to reflect changes, if applicable
  • This PR maintains or improves overall codebase code coverage.
  • Changes are added to the CHANGELOG. See the docs for information about adding to the changelog.

@codecov-commenter
Copy link

codecov-commenter commented May 4, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (70efbb6) 90.33% compared to head (79036b4) 90.33%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1114   +/-   ##
=======================================
  Coverage   90.33%   90.33%           
=======================================
  Files          48       48           
  Lines        6321     6321           
  Branches      941      941           
=======================================
  Hits         5710     5710           
  Misses        429      429           
  Partials      182      182           
Impacted Files Coverage Δ
pystac/link.py 90.35% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jsignell jsignell requested a review from gadomski May 4, 2023 20:31
@jsignell jsignell self-assigned this May 4, 2023
@gadomski gadomski added this to the 1.8 milestone May 4, 2023
@gadomski gadomski added this pull request to the merge queue May 8, 2023
Merged via the queue into stac-utils:main with commit 11613a1 May 8, 2023
@jsignell jsignell deleted the str-enum branch May 15, 2023 12:21
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.

3 participants