Skip to content

Commit 389d7b2

Browse files
author
Jonny Johannes
committed
explicit text link is redundant to link facet prints
1 parent 8bdadc3 commit 389d7b2

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

abstractions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class AdoptablePet:
1616
species: str # "dog" or "cat"
1717
breed: str
1818
location: str
19+
adoption_url: str
20+
image_url: str
1921
description: str = ""
20-
adoption_url: str | None = None
21-
image_url: str | None = None
2222
age_string: str | None = None
2323
sex: str | None = None
2424
size_group: str | None = None
@@ -50,8 +50,8 @@ class Post:
5050
"""Represents a social media post about an adoptable pet."""
5151

5252
text: str
53-
image_url: str | None = None
54-
link: str | None = None
53+
image_url: str
54+
link: str
5555
alt_text: str | None = None # For image accessibility
5656
tags: list[str] = field(default_factory=list)
5757

social_posters/bluesky.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,15 @@ def _build_text_and_facets(self, post: Post) -> tuple[str, list]:
155155

156156
tag_strings = [f"#{tag}" for tag in (post.tags) if tag]
157157
tags_section = " ".join(tag_strings)
158-
link_section = post.link
159-
# Truncate body so the full text (body + link + tags + separators) fits in limit chars.
160-
max_body = limit - len(separator) - len(link_section) - len(separator) - len(tags_section)
161-
full_text = f"{body[:max_body]}{separator}{link_section}{separator}{tags_section}"
158+
# Truncate body so the full text (body + separators + tags) fits in limit chars.
159+
max_body = limit - len(separator) - len(tags_section)
160+
full_text = f"{body[:max_body]}{separator}{tags_section}"
162161

163162
encoded = full_text.encode("utf-8")
164163

165164
link_bytes = post.link.encode("utf-8")
166165
link_idx = encoded.find(link_bytes)
167-
if link_idx != -1:
168-
facets.append({
166+
if link_idx != -1: facets.append({
169167
"index": {
170168
"byteStart": link_idx,
171169
"byteEnd": link_idx + len(link_bytes),

0 commit comments

Comments
 (0)