Pyright typing cleanup plan¶
uid: ISS-0026 status: BACKLOG priority: medium owner_role: REWORK estimate: TBD dependencies: [] risk: medium milestone: backlog
Pyright currently reports ~262 errors across CLI, flows, models, render, and tooling. This plan tracks goals and phased fixes.
Goals¶
- Bring Pyright to zero errors on the codebase under
./scripts/pyright.shusing the config inpyproject.toml. - Avoid behavior changes; prioritize typing correctness and narrow annotations.
- Keep changes incremental with passing pytest.
Scope¶
- CLI and flow argument types (
cli.py,filare.py,flows/build_harness.py,parser/harness_parser.py). - Model construction and validators (BOM, cable, metadata, partnumber, template inputs).
- Render utilities (graphviz/html/html_utils/pdf).
- Harness/index table typing.
Phased steps¶
- CLI/entrypoints: Fix
cli.pyandfilare.pysignatures and data shims; ensure tuples/sets are coerced to expected types. - Flows/build_harness: Type the connection/templates metadata and resolve Optional Path/str issues; adjust helper signatures for dict/model unions.
- Parser: Narrow YAML merge function inputs (List vs tuple).
- Models (BOM/partnumber/cable/component): Clean setter overloads, Optional handling, and enum coercions; fix logging reference in
bom.py. - Render (graphviz/html/pdf/html_utils): Align return types (Table vs str), handle optional ImportedSVGOptions, and correct iterable types.
- Harness/index_table: Fix tuple/list type expressions and Optional fields.
- Final sweep: Re-run Pyright and pytest; document remaining suppressions if any.
Progress¶
- [ ] Step 1: CLI/entrypoints
- [ ] Step 2: Flows/build_harness
- [ ] Step 3: Parser
- [ ] Step 4: Models (BOM/partnumber/cable/component) — in progress
- [ ] Step 5: Render
- [ ] Step 6: Harness/index_table
- [ ] Step 7: Final sweep (pyright + pytest)
Models progress (Step 4)¶
- Adjusted
models/bom.pyqty_multiplier typing and added logging import. - Updated
models/utils.pysignature forsmart_file_resolve(broader path types). - Guarded NumberAndUnit arithmetic against
None.
Notes¶
- Use minimal structural changes; prefer explicit casts/narrowing helpers where inputs are permissive.
- If any change appears user-visible, pause and consult.***