Repository navigation
Only explicitly support 3.10 and up. - #186
Merged
Merged
Conversation
jbarry-bdai
approved these changes
May 7, 2026
taughz
pushed a commit
that referenced
this pull request
Oct 13, 2026
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per discussion with @jbarry-bdai and @petercorke, we're going to remove explicit support for python version less than 3.10 because the type hint system is just better from that version onwards.
This also seems to fix the unit tests consistently failing issue.