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: don't transform_href in __getstate__ #1337

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

## [Unreleased]

- Allow object ID as input for getting APILayoutStrategy hrefs and add `items`, `collections`, `search`, `conformance`, `service_desc` and `service_doc` href methods. ([#1335](https://github.com/stac-utils/pystac/pull/1335))
### Fixed

- Don't transform hrefs in `Item.__getstate__` ([#1337](https://github.com/stac-utils/pystac/pull/1337))
- Allow object ID as input for getting APILayoutStrategy hrefs and add `items`, `collections`, `search`, `conformance`, `service_desc` and `service_doc` href methods. ([#1335](https://github.com/stac-utils/pystac/pull/1335))

## [v1.10.0] - 2024-03-28

Expand Down
7 changes: 6 additions & 1 deletion pystac/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ def __getstate__(self) -> dict[str, Any]:
d = self.__dict__.copy()

d["links"] = [
link.to_dict() if link.get_href() else link for link in d["links"]
(
link.to_dict(transform_href=False)
if link.get_href(transform_href=False)
else link
)
for link in d["links"]
]

return d
Expand Down
10 changes: 10 additions & 0 deletions tests/test_item.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import copy
import json
import os
import pickle
Expand Down Expand Up @@ -682,3 +683,12 @@ def test_pickle_with_only_href_links(item: Item) -> None:
assert original.media_type == new.media_type
assert str(original.owner) == str(new.owner)
assert str(original.target) == str(new.target)


def test_copy_with_unresolveable_root(item: Item) -> None:
item.add_link(
pystac.Link(
"root", "s3://naip-visualization/this-is-a-non-existent-catalog.json"
)
)
copy.deepcopy(item)
Loading