Skip to content

Commit 4f31e3b

Browse files
committed
Rename Link.properties to Link.extra_fields
1 parent 6d78dbd commit 4f31e3b

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

pystac/extensions/label.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,15 +619,15 @@ def add_source(
619619
assets : Optional list of assets that determine what
620620
assets in the source item this label item data applies to.
621621
"""
622-
properties = None
622+
extra_fields = None
623623
if assets is not None:
624-
properties = {"label:assets": assets}
624+
extra_fields = {"label:assets": assets}
625625
link = pystac.Link(
626626
"source",
627627
source_item,
628628
title=title,
629629
media_type=pystac.MediaType.JSON,
630-
properties=properties,
630+
extra_fields=extra_fields,
631631
)
632632
self.obj.add_link(link)
633633

pystac/link.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Link:
4343
media_type : Optional description of the media type. Registered Media Types
4444
are preferred. See :class:`~pystac.MediaType` for common media types.
4545
title : Optional title for this link.
46-
properties : Optional, additional properties for this link. This is used
46+
extra_fields : Optional, additional fields for this link. This is used
4747
by extensions as a way to serialize and deserialize properties on link
4848
object JSON.
4949
"""
@@ -64,8 +64,8 @@ class Link:
6464
title: Optional[str]
6565
"""Optional title for this link."""
6666

67-
properties: Optional[Dict[str, Any]]
68-
"""Optional, additional properties for this link. This is used by extensions as a
67+
extra_fields: Dict[str, Any]
68+
"""Optional, additional fields for this link. This is used by extensions as a
6969
way to serialize and deserialize properties on link object JSON."""
7070

7171
owner: Optional["STACObject_Type"]
@@ -79,13 +79,13 @@ def __init__(
7979
target: Union[str, "STACObject_Type"],
8080
media_type: Optional[str] = None,
8181
title: Optional[str] = None,
82-
properties: Optional[Dict[str, Any]] = None,
82+
extra_fields: Optional[Dict[str, Any]] = None,
8383
) -> None:
8484
self.rel = rel
8585
self.target = target
8686
self.media_type = media_type
8787
self.title = title
88-
self.properties = properties
88+
self.extra_fields = extra_fields or {}
8989
self.owner = None
9090

9191
def set_owner(self, owner: Optional["STACObject_Type"]) -> "Link":
@@ -260,9 +260,8 @@ def to_dict(self) -> Dict[str, Any]:
260260
if self.title is not None:
261261
d["title"] = self.title
262262

263-
if self.properties:
264-
for k, v in self.properties.items():
265-
d[k] = v
263+
for k, v in self.extra_fields.items():
264+
d[k] = v
266265

267266
return d
268267

@@ -299,16 +298,16 @@ def from_dict(d: Dict[str, Any]) -> "Link":
299298
media_type = d.pop("type", None)
300299
title = d.pop("title", None)
301300

302-
properties = None
301+
extra_fields = None
303302
if any(d):
304-
properties = d
303+
extra_fields = d
305304

306305
return Link(
307306
rel=rel,
308307
target=href,
309308
media_type=media_type,
310309
title=title,
311-
properties=properties,
310+
extra_fields=extra_fields,
312311
)
313312

314313
@staticmethod

tests/test_link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_relative(self) -> None:
5858
rel = "my rel"
5959
target = "../elsewhere"
6060
mime_type = "example/stac_thing"
61-
link = pystac.Link(rel, target, mime_type, "a title", properties={"a": "b"})
61+
link = pystac.Link(rel, target, mime_type, "a title", extra_fields={"a": "b"})
6262
expected_dict = {
6363
"rel": rel,
6464
"href": target,

0 commit comments

Comments
 (0)