Skip to content

Commit

Permalink
fix(readwise): all datetime fields are now optional
Browse files Browse the repository at this point in the history
  • Loading branch information
rwxd committed Mar 27, 2023
1 parent 31625d2 commit 6017c64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions readwise/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def get_books(
last_highlight_at=datetime.fromisoformat(book['last_highlight_at'])
if book['last_highlight_at']
else None,
updated=datetime.fromisoformat(book['updated']),
updated=datetime.fromisoformat(book['updated'])
if book['updated']
else None,
cover_image_url=book['cover_image_url'],
highlights_url=book['highlights_url'],
source_url=book['source_url'],
Expand Down Expand Up @@ -270,7 +272,9 @@ def get_book_highlights(
location_type=highlight['location_type'],
url=highlight['url'],
color=highlight['color'],
updated=datetime.fromisoformat(highlight['updated']),
updated=datetime.fromisoformat(highlight['updated'])
if highlight['updated']
else None,
book_id=highlight['book_id'],
tags=[
ReadwiseTag(id=tag['id'], name=tag['name'])
Expand Down
4 changes: 2 additions & 2 deletions readwise/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ReadwiseBook:
source: str
num_highlights: int
last_highlight_at: datetime | None
updated: datetime
updated: datetime | None
cover_image_url: str
highlights_url: str
source_url: str
Expand Down Expand Up @@ -78,6 +78,6 @@ class ReadwiseHighlight:
location_type: str
url: str | None
color: str
updated: datetime
updated: datetime | None
book_id: str
tags: list[ReadwiseTag]

0 comments on commit 6017c64

Please sign in to comment.