chore(core): make ty the default typechecker (#736)

Signed-off-by: phernandez <paul@basicmachines.co>
This commit is contained in:
Paul Hernandez
2026-04-13 10:34:01 -05:00
committed by GitHub
parent abd4a5a6da
commit 052545b661
89 changed files with 1004 additions and 559 deletions
+34 -15
View File
@@ -60,6 +60,11 @@ class EntityWriteResult:
search_content: str
def _frontmatter_permalink(value: object) -> str | None:
"""Return an explicit frontmatter permalink only when YAML parsed a real string."""
return value if isinstance(value, str) and value else None
class EntityService(BaseService[EntityModel]):
"""Service for managing entities in the database."""
@@ -287,9 +292,13 @@ class EntityService(BaseService[EntityModel]):
schema.note_type = content_frontmatter["type"]
if "permalink" in content_frontmatter:
content_markdown = self._build_frontmatter_markdown(
schema.title, schema.note_type, content_frontmatter["permalink"]
)
content_permalink = _frontmatter_permalink(content_frontmatter["permalink"])
if content_permalink is not None:
content_markdown = self._build_frontmatter_markdown(
schema.title,
schema.note_type,
content_permalink,
)
# Get unique permalink (prioritizing content frontmatter) unless disabled
if self.app_config and self.app_config.disable_permalinks:
@@ -392,9 +401,13 @@ class EntityService(BaseService[EntityModel]):
schema.note_type = content_frontmatter["type"]
if "permalink" in content_frontmatter:
content_markdown = self._build_frontmatter_markdown(
schema.title, schema.note_type, content_frontmatter["permalink"]
)
content_permalink = _frontmatter_permalink(content_frontmatter["permalink"])
if content_permalink is not None:
content_markdown = self._build_frontmatter_markdown(
schema.title,
schema.note_type,
content_permalink,
)
# Check if we need to update the permalink based on content frontmatter (unless disabled)
new_permalink = entity.permalink # Default to existing
@@ -521,9 +534,13 @@ class EntityService(BaseService[EntityModel]):
schema.note_type = content_frontmatter["type"]
if "permalink" in content_frontmatter:
content_markdown = self._build_frontmatter_markdown(
schema.title, schema.note_type, content_frontmatter["permalink"]
)
content_permalink = _frontmatter_permalink(content_frontmatter["permalink"])
if content_permalink is not None:
content_markdown = self._build_frontmatter_markdown(
schema.title,
schema.note_type,
content_permalink,
)
# --- Permalink Resolution ---
if self.app_config and self.app_config.disable_permalinks:
@@ -662,11 +679,13 @@ class EntityService(BaseService[EntityModel]):
update_data["note_type"] = _coerce_to_string(content_frontmatter["type"])
if "permalink" in content_frontmatter:
content_markdown = self._build_frontmatter_markdown(
update_data.get("title", entity.title),
update_data.get("note_type", entity.note_type),
content_frontmatter["permalink"],
)
content_permalink = _frontmatter_permalink(content_frontmatter["permalink"])
if content_permalink is not None:
content_markdown = self._build_frontmatter_markdown(
_coerce_to_string(update_data.get("title", entity.title)),
_coerce_to_string(update_data.get("note_type", entity.note_type)),
content_permalink,
)
metadata = normalize_frontmatter_metadata(content_frontmatter or {})
update_data["entity_metadata"] = {k: v for k, v in metadata.items() if v is not None}
@@ -1002,7 +1021,7 @@ class EntityService(BaseService[EntityModel]):
target_entity: Optional[Entity] = None
if not isinstance(resolved, Exception):
# Type narrowing: resolved is Optional[Entity] here, not Exception
target_entity = resolved # type: ignore
target_entity = resolved
# if the target is found, store the id
target_id = target_entity.id if target_entity else None