Skip to content

Commit 6d78dbd

Browse files
committed
Add type annotations for Link attributes
1 parent a4fe4cd commit 6d78dbd

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

pystac/link.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,33 @@ class Link:
4646
properties : Optional, additional properties for this link. This is used
4747
by extensions as a way to serialize and deserialize properties on link
4848
object JSON.
49-
50-
Attributes:
51-
rel : The relation of the link (e.g. 'child', 'item'). Registered rel Types
52-
are preferred. See :class:`~pystac.RelType` for common media types.
53-
target : The target of the link. If the link is
54-
unresolved, or the link is to something that is not a STACObject,
55-
the target is an HREF. If resolved, the target is a STACObject.
56-
media_type : Optional description of the media type.
57-
Registered Media Types are preferred. See
58-
:class:`~pystac.MediaType` for common media types.
59-
title : Optional title for this link.
60-
properties : Optional, additional properties for this link.
61-
This is used by extensions as a way to serialize and deserialize properties
62-
on link object JSON.
63-
owner : The owner of this link. The link will use
64-
its owner's root catalog
65-
:class:`~pystac.resolved_object_cache.ResolvedObjectCache` to resolve
66-
objects, and will create absolute HREFs from relative HREFs against
67-
the owner's self HREF.
6849
"""
6950

51+
rel: Union[str, pystac.RelType]
52+
"""The relation of the link (e.g. 'child', 'item'). Registered rel Types are
53+
preferred. See :class:`~pystac.RelType` for common media types."""
54+
55+
target: Union[str, "STACObject_Type"]
56+
"""The target of the link. If the link is unresolved, or the link is to something
57+
that is not a STACObject, the target is an HREF. If resolved, the target is a
58+
STACObject."""
59+
60+
media_type: Optional[str]
61+
"""Optional description of the media type. Registered Media Types are preferred.
62+
See :class:`~pystac.MediaType` for common media types."""
63+
64+
title: Optional[str]
65+
"""Optional title for this link."""
66+
67+
properties: Optional[Dict[str, Any]]
68+
"""Optional, additional properties for this link. This is used by extensions as a
69+
way to serialize and deserialize properties on link object JSON."""
70+
71+
owner: Optional["STACObject_Type"]
72+
"""The owner of this link. The link will use its owner's root catalog
73+
:class:`~pystac.resolved_object_cache.ResolvedObjectCache` to resolve objects, and
74+
will create absolute HREFs from relative HREFs against the owner's self HREF."""
75+
7076
def __init__(
7177
self,
7278
rel: Union[str, pystac.RelType],
@@ -76,11 +82,11 @@ def __init__(
7682
properties: Optional[Dict[str, Any]] = None,
7783
) -> None:
7884
self.rel = rel
79-
self.target: Union[str, "STACObject_Type"] = target # An object or an href
85+
self.target = target
8086
self.media_type = media_type
8187
self.title = title
8288
self.properties = properties
83-
self.owner: Optional["STACObject_Type"] = None
89+
self.owner = None
8490

8591
def set_owner(self, owner: Optional["STACObject_Type"]) -> "Link":
8692
"""Sets the owner of this link.

0 commit comments

Comments
 (0)