Skip to content

Commit 8455bd9

Browse files
authored
refactor(base): collapse the three-way Python-version type shim into one file (#212)
## Summary Step 1 of a broader type-hint cleanup pass (cc @jbarry-bdai — following on from our email thread on this). Opening this narrow, mechanical piece first to get it moving while the rest gets scoped out. `spatialmath/base/types.py` dispatched on `sys.version_info` across three duplicate files (`_types_35.py`, `_types_39.py`, `_types_311.py`, ~465 lines total), from when Python 3.5-3.10 support coexisted. `pyproject.toml` has required `>=3.10` since #186, so `_types_35.py` could never actually be reached, and `_types_39`/`_types_311` differed only in where `Self` is imported from (`typing_extensions` vs `typing`). This collapses all three into a single ~170-line file with a two-line version check. No aliases or exported names changed — purely a dedup, verified by a full test suite pass (343 passed). ## What's next This is deliberately the smallest, lowest-risk slice. A quick survey of the rest of the package turned up the following, to be tackled in follow-up PRs: - **Annotation coverage is uneven.** 838 functions/methods surveyed across `spatialmath/` and `spatialmath/base/`: 57.5% fully annotated overall. Most of `base/` is in decent shape (72-96%), but `animate.py` is only 6% annotated. Top-level is weaker — `pose2d.py`, `spatialvector.py`, and `twist.py` are all at 0%. - **Old-style typing syntax is still widespread.** `Optional[X]`, `Union[X, Y]`, `List[X]` etc. appear ~400+ times across the package (heaviest in `graphics.py` at 124 occurrences) and can move to `X | None` / `X | Y` / `list[X]` now that 3.10+ is the floor. Planned sequencing: this shim collapse, then a mechanical syntax-modernization pass, then filling the real coverage gaps (`twist.py`/`spatialvector.py`/`pose2d.py` first, then `animate.py`) as their own PR(s) since those need actual thought rather than find-replace.
1 parent 4477d43 commit 8455bd9

4 files changed

Lines changed: 166 additions & 472 deletions

File tree

‎spatialmath/base/_types_311.py‎

Lines changed: 0 additions & 157 deletions
This file was deleted.

‎spatialmath/base/_types_35.py‎

Lines changed: 0 additions & 150 deletions
This file was deleted.

0 commit comments

Comments
 (0)