Skip to content

Commit 352ae38

Browse files
authored
Merge branch 'main' into feature/raster-collection-extension
2 parents d9fd08e + 2175c14 commit 352ae38

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Use `pyproject.toml` instead of `setup.py` ([#1100](https://github.com/stac-utils/pystac/pull/1100))
2121
- `DefaultStacIO` now raises an error if it tries to write to a non-local url ([#1107](https://github.com/stac-utils/pystac/pull/1107))
2222
- Allow instantiation of pystac objects even with `"stac_extensions": null` ([#1109](https://github.com/stac-utils/pystac/pull/1109))
23+
- Make `Link.to_dict()` only contain strings ([#1114](https://github.com/stac-utils/pystac/pull/1114))
2324

2425
### Deprecated
2526

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test = [
6161
"pytest-mock~=3.10",
6262
"pytest-vcr~=1.0",
6363
"pytest~=7.3",
64-
"ruff==0.0.264",
64+
"ruff==0.0.265",
6565
"types-html5lib~=1.1",
6666
"types-orjson~=3.6",
6767
"types-python-dateutil~=2.8",

pystac/link.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Link(PathLike):
6767
"""The relation of the link (e.g. 'child', 'item'). Registered rel Types are
6868
preferred. See :class:`~pystac.RelType` for common media types."""
6969

70-
media_type: Optional[str]
70+
media_type: Optional[Union[str, pystac.MediaType]]
7171
"""Optional description of the media type. Registered Media Types are preferred.
7272
See :class:`~pystac.MediaType` for common media types."""
7373

@@ -88,7 +88,7 @@ def __init__(
8888
self,
8989
rel: Union[str, pystac.RelType],
9090
target: Union[str, STACObject],
91-
media_type: Optional[str] = None,
91+
media_type: Optional[Union[str, pystac.MediaType]] = None,
9292
title: Optional[str] = None,
9393
extra_fields: Optional[Dict[str, Any]] = None,
9494
) -> None:
@@ -372,12 +372,12 @@ def to_dict(self, transform_href: bool = True) -> Dict[str, Any]:
372372
"""
373373

374374
d: Dict[str, Any] = {
375-
"rel": self.rel,
375+
"rel": str(self.rel),
376376
"href": self.get_href(transform_href=transform_href),
377377
}
378378

379379
if self.media_type is not None:
380-
d["type"] = self.media_type
380+
d["type"] = str(self.media_type)
381381

382382
if self.title is not None:
383383
d["title"] = self.title

tests/test_link.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ def test_serialize_link(self) -> None:
205205
link = pystac.Link(pystac.RelType.SELF, href, pystac.MediaType.JSON, title)
206206
link_dict = link.to_dict()
207207

208-
self.assertEqual(str(link_dict["rel"]), "self")
209-
self.assertEqual(str(link_dict["type"]), "application/json")
208+
self.assertEqual(link_dict["rel"], "self")
209+
self.assertEqual(link_dict["type"], "application/json")
210210
self.assertEqual(link_dict["title"], title)
211211
self.assertEqual(link_dict["href"], href)
212212

0 commit comments

Comments
 (0)