7e-1a: QA nits cleanup -- redundant assignment + test helper hygiene #114
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/pal-e-api!114
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "111-7e-1a-qa-nits-cleanup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
html_content=body.html_contentassignment increate_note()sinceparse_and_store_blocks()overwrites it immediately_get_compiled_page()detach-safeChanges
src/pal_e_docs/routes/notes.py: Changedhtml_content=body.html_contenttohtml_content=""in the Note constructor with explanatory commenttests/test_note_block_sync.py: Added block comment documenting why helpers use separateTestingSessionLocal()sessions; added docstrings to all three helpers; converted_get_compiled_page()to return a plain dict instead of a detached SQLAlchemy instance; updated all callers to dict access; replaced inline session usage intest_compiled_page_matches_note_htmlwith API call + helperTest Plan
ruff checkandruff format --checkpassReview Checklist
Related
plan-2026-02-26-tf-modularize-postgres-- Phase 7e-1aPR #114 Review
BLOCKERS
None.
NITS
_get_compiled_pagereturn type annotation usesdict | None(Python 3.10+ union syntax) -- This is fine as long as the project's minimum Python version supports it. Consistent with the rest of the codebase so no action needed, just noting it._count_blocksand_get_blockswere not given return type annotations -- The PR added a return type to_get_compiled_page(-> dict | None) and docstrings to all three helpers, but the other two helpers still lack return type annotations on their signatures. Minor inconsistency, non-blocking.CODE REVIEW
notes.pychange (line 273): Correct.parse_and_store_blocks()atblocks/sync.py:68overwritesnote.html_contentwith compiled output viarecompile_note(). Setting it to""instead ofbody.html_contenteliminates a redundant assignment and makes the data flow clearer. The guard at line 286 (if body.html_content:) means the empty string is never persisted for notes with actual content -- they always go throughparse_and_store_blocks.test_note_block_sync.pychanges:_get_compiled_page()to return a plain dict eliminates a real risk of detached-instance errors aftersession.close(). The current code on main accessescompiled.content_hashandcompiled.toc_jsonafter the session is closed in thefinallyblock -- this works by accident (lazy loading already resolved) but is fragile. The dict approach is correct.compiled.content_hash) to dict access (compiled["content_hash"]).test_compiled_page_matches_note_htmlrefactored to use API call + helper instead of inline session -- consistent with the documented pattern and eliminates the last inlineTestingSessionLocal()usage in test methods.SOP COMPLIANCE
111-7e-1a-qa-nits-cleanupreferences issue #111)plan-2026-02-26-tf-modularize-postgres)Closes forgejo_admin/pal-e-docs #111)VERDICT: APPROVED