Skip to content

Commit

Permalink
fix: lints
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Feb 14, 2025
1 parent 7f2214c commit c49343a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/pystac/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,14 @@ def set_collection(self, collection: Collection | None) -> None:
self.remove_links(COLLECTION)

def get_collection(self) -> Collection | None:
from .collection import Collection

if link := self.get_link(COLLECTION):
return link.get_stac_object()
stac_object = link.get_stac_object()
if isinstance(stac_object, Collection):
return stac_object
else:
return None
else:
return None

Expand Down Expand Up @@ -154,7 +160,7 @@ def _to_dict(self) -> dict[str, Any]:
return d


def _parse_datetime(value: str | dt.datetime | None) -> dt.datetime:
def _parse_datetime(value: str | dt.datetime | None) -> dt.datetime | None:
if value is None or isinstance(value, dt.datetime):
return value
else:
Expand Down
2 changes: 1 addition & 1 deletion src/pystac/stac_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def set_self_link(self) -> None:
self.set_link(Link.self(self))

@deprecate.function("Prefer to get the href directly")
def get_self_href(self) -> str:
def get_self_href(self) -> str | None:
return self.href

@deprecate.function("Prefer to set href directly, and then use `render()`")
Expand Down
2 changes: 1 addition & 1 deletion src/pystac/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def datetime_to_str(dt: datetime.datetime, timespec: str = "auto") -> str:
return timestamp


def str_to_datetime(s: str) -> datetime:
def str_to_datetime(s: str) -> datetime.datetime:
return dateutil.parser.isoparse(s)


Expand Down

0 comments on commit c49343a

Please sign in to comment.