oe-lsp-pyright-refactor
Workflow (shim-first, LSP-first)
Before changes:
- Use LSP to find the definition, outgoing calls, and references for the symbols you will move/rename.
- Inventory importers before moving modules (including dynamic imports).
During refactor:
- Keep public surfaces stable with re-exports/thin wrappers first.
- Prefer moving pure helpers/constants before orchestration.
After each PR-sized step:
- Use Pyright/LSP diagnostics to catch Optional leaks, wrong return types, and missing attributes.
- Fix the contract at the boundary (Protocol/TypedDict) rather than sprinkling
Any.
Canonical plans
- Use
docs/internal/BACKEND_REFACTORING_PLAN_DEC_2025.mdfor step-file ladders and preserve sets. - Use
docs/internal/BACKEND_REFACTORING_PLAN_DEC_2025_ADDENDUM.mdfor production hardening + PH5 typing work.
Common refactor targets (Pyright tends to catch first)
- Adapter interfaces: define
Protocols for optional capabilities instead ofhasattr-only contracts. - API boundary models: ensure required fields never receive
None(or model them as Optional intentionally). - “stringly typed” payloads: introduce TypedDicts for
event_entry,draft_messages,process_msgoutput.