chore: ran linting

This commit is contained in:
Anish Sarkar 2026-04-22 06:40:39 +05:30
parent 4a75603d4f
commit 3eb4d55ef5
17 changed files with 369 additions and 201 deletions

View file

@ -91,8 +91,7 @@ def downgrade() -> None:
)
conn.execute(
sa.text(
"DROP INDEX IF EXISTS "
"search_source_connectors_obsidian_plugin_vault_uniq"
"DROP INDEX IF EXISTS search_source_connectors_obsidian_plugin_vault_uniq"
)
)
conn.execute(

View file

@ -129,7 +129,9 @@ async def _finish_obsidian_sync_notification(
):
"""Mark the rolling Obsidian sync inbox item complete or failed."""
handler = NotificationService.connector_indexing
connector_name = notification.notification_metadata.get("connector_name", "Obsidian")
connector_name = notification.notification_metadata.get(
"connector_name", "Obsidian"
)
if failed > 0 and indexed == 0:
title = f"Failed: {connector_name}"
message = (
@ -273,9 +275,7 @@ async def _find_by_fingerprint(
return (await session.execute(stmt)).scalars().first()
def _build_config(
payload: ConnectRequest, *, now_iso: str
) -> dict[str, object]:
def _build_config(payload: ConnectRequest, *, now_iso: str) -> dict[str, object]:
return {
"vault_id": payload.vault_id,
"vault_name": payload.vault_name,
@ -456,9 +456,7 @@ async def obsidian_sync(
session, connector=connector, payload=note, user_id=str(user.id)
)
indexed += 1
items.append(
SyncAckItem(path=note.path, status="ok", document_id=doc.id)
)
items.append(SyncAckItem(path=note.path, status="ok", document_id=doc.id))
except HTTPException:
raise
except Exception as exc:
@ -597,9 +595,7 @@ async def obsidian_delete_notes(
path,
payload.vault_id,
)
items.append(
DeleteAckItem(path=path, status="error", error=str(exc)[:300])
)
items.append(DeleteAckItem(path=path, status="error", error=str(exc)[:300]))
return DeleteAck(
vault_id=payload.vault_id,
@ -616,9 +612,7 @@ async def obsidian_manifest(
session: AsyncSession = Depends(get_async_session),
) -> ManifestResponse:
"""Return ``{path: {hash, mtime}}`` for the plugin's onload reconcile diff."""
connector = await _resolve_vault_connector(
session, user=user, vault_id=vault_id
)
connector = await _resolve_vault_connector(session, user=user, vault_id=vault_id)
return await get_manifest(session, connector=connector, vault_id=vault_id)
@ -633,9 +627,7 @@ async def obsidian_stats(
``files_synced`` excludes tombstones so it matches ``/manifest``;
``last_sync_at`` includes them so deletes advance the freshness signal.
"""
connector = await _resolve_vault_connector(
session, user=user, vault_id=vault_id
)
connector = await _resolve_vault_connector(session, user=user, vault_id=vault_id)
is_active = Document.document_metadata["deleted_at"].as_string().is_(None)

View file

@ -24,10 +24,14 @@ class _PluginBase(BaseModel):
class NotePayload(_PluginBase):
"""One Obsidian note as pushed by the plugin (the source of truth)."""
vault_id: str = Field(..., description="Stable plugin-generated UUID for this vault")
vault_id: str = Field(
..., description="Stable plugin-generated UUID for this vault"
)
path: str = Field(..., description="Vault-relative path, e.g. 'notes/foo.md'")
name: str = Field(..., description="File stem (no extension)")
extension: str = Field(default="md", description="File extension without leading dot")
extension: str = Field(
default="md", description="File extension without leading dot"
)
content: str = Field(default="", description="Raw markdown body (post-frontmatter)")
frontmatter: dict[str, Any] = Field(default_factory=dict)
@ -38,7 +42,9 @@ class NotePayload(_PluginBase):
embeds: list[str] = Field(default_factory=list)
aliases: list[str] = Field(default_factory=list)
content_hash: str = Field(..., description="Plugin-computed SHA-256 of the raw content")
content_hash: str = Field(
..., description="Plugin-computed SHA-256 of the raw content"
)
size: int | None = Field(
default=None,
ge=0,

View file

@ -126,9 +126,7 @@ def _build_document_string(payload: NotePayload, vault_name: str) -> str:
existing search relevance heuristics keep working unchanged.
"""
tags_line = ", ".join(payload.tags) if payload.tags else "None"
links_line = (
", ".join(payload.resolved_links) if payload.resolved_links else "None"
)
links_line = ", ".join(payload.resolved_links) if payload.resolved_links else "None"
return (
"<METADATA>\n"
f"Title: {payload.name}\n"
@ -235,9 +233,7 @@ async def upsert_note(
if not prepared:
if existing is not None:
return existing
raise RuntimeError(
f"Indexing pipeline rejected obsidian note {payload.path}"
)
raise RuntimeError(f"Indexing pipeline rejected obsidian note {payload.path}")
document = prepared[0]

View file

@ -111,9 +111,7 @@ async def race_user_and_space(async_engine):
# connectors test creates documents, so we wipe them too. The
# CASCADE on user_id catches anything we missed.
await cleanup.execute(
text(
'DELETE FROM search_source_connectors WHERE user_id = :uid'
),
text("DELETE FROM search_source_connectors WHERE user_id = :uid"),
{"uid": user_id},
)
await cleanup.execute(
@ -156,9 +154,7 @@ class TestConnectRace:
)
await obsidian_connect(payload, user=fresh_user, session=s)
results = await asyncio.gather(
_call("a"), _call("b"), return_exceptions=True
)
results = await asyncio.gather(_call("a"), _call("b"), return_exceptions=True)
for r in results:
assert not isinstance(r, Exception), f"Connect raised: {r!r}"
@ -430,9 +426,7 @@ class TestWireContractSmoke:
assert {it.status for it in rename_resp.items} == {"ok", "missing"}
# snake_case fields are deliberate — the plugin decoder maps them
# to camelCase explicitly.
assert all(
it.old_path and it.new_path for it in rename_resp.items
)
assert all(it.old_path and it.new_path for it in rename_resp.items)
# 4. /notes DELETE
async def _delete(*args, **kwargs) -> bool:

View file

@ -202,9 +202,7 @@ class TestHTTPExceptionHandler:
# Intentional 503s (e.g. feature flag off) must surface the developer
# message so the frontend can render actionable copy.
body = _assert_envelope(client.get("/http-503"), 503)
assert (
body["error"]["message"] == "Page purchases are temporarily unavailable."
)
assert body["error"]["message"] == "Page purchases are temporarily unavailable."
assert body["error"]["message"] != GENERIC_5XX_MESSAGE
def test_502_preserves_detail(self, client):