mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-04 22:02:16 +02:00
chore: ran linting
This commit is contained in:
parent
e46b24a2b1
commit
a482cc95de
67 changed files with 4971 additions and 5539 deletions
|
|
@ -72,7 +72,9 @@ def _populate_source_markdown(conn, batch_size: int = 500) -> None:
|
|||
print("No documents with blocknote_document need migration")
|
||||
return
|
||||
|
||||
print(f" Migrating {total} documents (with blocknote_document) to source_markdown...")
|
||||
print(
|
||||
f" Migrating {total} documents (with blocknote_document) to source_markdown..."
|
||||
)
|
||||
|
||||
migrated = 0
|
||||
failed = 0
|
||||
|
|
|
|||
|
|
@ -107,8 +107,12 @@ def create_create_notion_page_tool(
|
|||
}
|
||||
)
|
||||
|
||||
decisions_raw = approval.get("decisions", []) if isinstance(approval, dict) else []
|
||||
decisions = decisions_raw if isinstance(decisions_raw, list) else [decisions_raw]
|
||||
decisions_raw = (
|
||||
approval.get("decisions", []) if isinstance(approval, dict) else []
|
||||
)
|
||||
decisions = (
|
||||
decisions_raw if isinstance(decisions_raw, list) else [decisions_raw]
|
||||
)
|
||||
decisions = [d for d in decisions if isinstance(d, dict)]
|
||||
if not decisions:
|
||||
logger.warning("No approval decision received")
|
||||
|
|
|
|||
|
|
@ -119,8 +119,12 @@ def create_delete_notion_page_tool(
|
|||
}
|
||||
)
|
||||
|
||||
decisions_raw = approval.get("decisions", []) if isinstance(approval, dict) else []
|
||||
decisions = decisions_raw if isinstance(decisions_raw, list) else [decisions_raw]
|
||||
decisions_raw = (
|
||||
approval.get("decisions", []) if isinstance(approval, dict) else []
|
||||
)
|
||||
decisions = (
|
||||
decisions_raw if isinstance(decisions_raw, list) else [decisions_raw]
|
||||
)
|
||||
decisions = [d for d in decisions if isinstance(d, dict)]
|
||||
if not decisions:
|
||||
logger.warning("No approval decision received")
|
||||
|
|
|
|||
|
|
@ -128,8 +128,12 @@ def create_update_notion_page_tool(
|
|||
}
|
||||
)
|
||||
|
||||
decisions_raw = approval.get("decisions", []) if isinstance(approval, dict) else []
|
||||
decisions = decisions_raw if isinstance(decisions_raw, list) else [decisions_raw]
|
||||
decisions_raw = (
|
||||
approval.get("decisions", []) if isinstance(approval, dict) else []
|
||||
)
|
||||
decisions = (
|
||||
decisions_raw if isinstance(decisions_raw, list) else [decisions_raw]
|
||||
)
|
||||
decisions = [d for d in decisions if isinstance(d, dict)]
|
||||
if not decisions:
|
||||
logger.warning("No approval decision received")
|
||||
|
|
|
|||
|
|
@ -126,9 +126,7 @@ async def get_editor_content(
|
|||
"title": document.title,
|
||||
"document_type": document.document_type.value,
|
||||
"source_markdown": markdown_content,
|
||||
"updated_at": document.updated_at.isoformat()
|
||||
if document.updated_at
|
||||
else None,
|
||||
"updated_at": document.updated_at.isoformat() if document.updated_at else None,
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -172,14 +170,10 @@ async def save_document(
|
|||
|
||||
source_markdown = data.get("source_markdown")
|
||||
if source_markdown is None:
|
||||
raise HTTPException(
|
||||
status_code=400, detail="source_markdown is required"
|
||||
)
|
||||
raise HTTPException(status_code=400, detail="source_markdown is required")
|
||||
|
||||
if not isinstance(source_markdown, str):
|
||||
raise HTTPException(
|
||||
status_code=400, detail="source_markdown must be a string"
|
||||
)
|
||||
raise HTTPException(status_code=400, detail="source_markdown must be a string")
|
||||
|
||||
# For NOTE type, extract title from first heading line if present
|
||||
if document.document_type == DocumentType.NOTE:
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ logger = logging.getLogger(__name__)
|
|||
# Inline content → markdown text
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _render_inline_content(content: list[dict[str, Any]] | None) -> str:
|
||||
"""Convert BlockNote inline content array to a markdown string."""
|
||||
if not content:
|
||||
|
|
@ -215,6 +216,7 @@ def _render_block(block: dict[str, Any], indent: int = 0) -> list[str]:
|
|||
# Public API
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def blocknote_to_markdown(
|
||||
blocks: list[dict[str, Any]] | dict[str, Any] | None,
|
||||
) -> str | None:
|
||||
|
|
@ -248,7 +250,9 @@ def blocknote_to_markdown(
|
|||
blocks = [blocks]
|
||||
|
||||
if not isinstance(blocks, list):
|
||||
logger.warning(f"blocknote_to_markdown received unexpected type: {type(blocks)}")
|
||||
logger.warning(
|
||||
f"blocknote_to_markdown received unexpected type: {type(blocks)}"
|
||||
)
|
||||
return None
|
||||
|
||||
all_lines: list[str] = []
|
||||
|
|
@ -272,10 +276,10 @@ def blocknote_to_markdown(
|
|||
# Add a blank line between blocks (standard markdown spacing)
|
||||
# Exception: consecutive list items of the same type don't get extra blank lines
|
||||
if all_lines and block_lines:
|
||||
same_list = (
|
||||
(block_type == prev_type and block_type in (
|
||||
"bulletListItem", "numberedListItem", "checkListItem"
|
||||
))
|
||||
same_list = block_type == prev_type and block_type in (
|
||||
"bulletListItem",
|
||||
"numberedListItem",
|
||||
"checkListItem",
|
||||
)
|
||||
if not same_list:
|
||||
all_lines.append("")
|
||||
|
|
@ -285,4 +289,3 @@ def blocknote_to_markdown(
|
|||
|
||||
result = "\n".join(all_lines).strip()
|
||||
return result if result else None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue