refactor(base): collapse the three-way Python-version type shim into one file - #212
Open
petercorke wants to merge 1 commit into
Open
refactor(base): collapse the three-way Python-version type shim into one file#212petercorke wants to merge 1 commit into
petercorke wants to merge 1 commit into
Conversation
…one file spatialmath/base/types.py dispatched on sys.version_info across _types_35.py, _types_39.py and _types_311.py, from when Python 3.5-3.10 support coexisted. pyproject.toml has required Python >=3.10 since rai-opensource#186, so _types_35.py could never be reached, and _types_39/_types_311 differed only in where Self is imported from. Collapse to a single file with a two-line version check; no change to the names or aliases it exports.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
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.pydispatched onsys.version_infoacross 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.tomlhas required>=3.10since #186, so_types_35.pycould never actually be reached, and_types_39/_types_311differed only in whereSelfis imported from (typing_extensionsvstyping). 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:
spatialmath/andspatialmath/base/: 57.5% fully annotated overall. Most ofbase/is in decent shape (72-96%), butanimate.pyis only 6% annotated. Top-level is weaker —pose2d.py,spatialvector.py, andtwist.pyare all at 0%.Optional[X],Union[X, Y],List[X]etc. appear ~400+ times across the package (heaviest ingraphics.pyat 124 occurrences) and can move toX | 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.pyfirst, thenanimate.py) as their own PR(s) since those need actual thought rather than find-replace.