rename: Path -> Polyline, avoids clashing with pathlib.Path - #42
Merged
Conversation
Path is an extremely overloaded name (pathlib.Path, matplotlib.path.Path, os.path) -- RTB in particular imports pathlib.Path pervasively, so any RTB code that also wants spatialgeometry's polyline shape needs an import alias just to avoid shadowing. The class's own docstring already called itself "a polyline through a sequence of waypoints", so Polyline is the more accurate name too, not just a workaround. Path has been in a released version since 1.3.0 (currently on PyPI), so kept as a deprecated alias -- same pattern as Box -> Cuboid: a subclass that warns FutureWarning in __init__ then delegates to super(). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 tasks
petercorke
added a commit
to jhavl/swift
that referenced
this pull request
Aug 9, 2026
spatialgeometry renamed the Python class Path -> Polyline (avoids clashing with pathlib.Path -- jhavl/spatialgeometry#42), keeping Path as a deprecated (FutureWarning) alias. Migrates swift's one direct reference (test_protocol.py). The wire-protocol stype string deliberately stays "path" -- changing that too would be a breaking protocol change for a rename that's purely cosmetic on the Python side -- so shapes.js needed comments explaining the naming disparity, not a code change.
3 tasks
petercorke
added a commit
to jhavl/swift
that referenced
this pull request
Aug 16, 2026
pytest tests/ -v (CI's invocation) doesn't add the repo root to sys.path, so tests/test_lights.py's `from tests.test_protocol import ...` has failed at collection on every run since it landed on 2026-08-07/09 -- every PR since (#113-#122) inherited this, unrelated to what any of them actually changed. Add pythonpath = ["."] to pytest's ini options, matching what `python -m pytest` already does implicitly. With collection fixed, one real failure surfaces: tests/test_protocol.py constructs sg.Polyline(...), but spatialgeometry's Path->Polyline rename (jhavl/spatialgeometry#42) merged to its main branch after the last PyPI release (1.3.0), so plain `pip install spatialgeometry` in CI doesn't have it yet. Pin CI to spatialgeometry@main, mirroring the existing roboticstoolbox-python workaround in the same workflow. Verified against SG's current main: swift's full 99-test suite passes, and Path is kept as a working deprecated alias (FutureWarning only), so this isn't a breaking change for swift.
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
Pathis renamed toPolyline-- it's a heavily overloaded name(
pathlib.Path,matplotlib.path.Path,os.path) and RTB in particularimports
pathlib.Pathpervasively, so any RTB code that also wants thisshape needs an import alias just to avoid shadowing. The class's own
docstring already called itself "a polyline through a sequence of
waypoints", so
Polylineis the more accurate name too, not just aworkaround.
Pathhas been in a released version since 1.3.0 (currently on PyPI),so it's kept as a deprecated alias rather than removed outright -- same
pattern as
Box->Cuboid: a subclass that raisesFutureWarningin__init__then delegates tosuper().stype="path") is left unchanged -- it's aninternal renderer identifier, not the Python API surface causing the
clash, and touching it would need a synchronized change on the Swift
side for no real benefit.
api.rst) and tests updated to match;Polylinegets the primaryentry,
Pathstill gets its own (deprecated) autoclass entry, sametreatment as
Boxgets today.Test plan
pytest tests/test_Shape.py tests/test_collision.py-- 170 passedtest_Path_warns_and_is_a_polylinecovers the deprecation:warns
FutureWarning,isinstance(x, Polyline)holds, behaviourunchanged
repr()correctly distinguishesPath(...)fromPolyline(...),matching existing
Box/Cuboidbehaviourdocs && make html-- clean, no new warnings introduced (33pre-existing, unrelated
SceneNodeduplicate-description warnings)spatialgeometry.Path/gm.Pathusage -- none found, so nothing external breaks even without the
deprecation shim; the shim covers any WIP code not yet checked in
🤖 Generated with Claude Code