Skip to content

fix: Edge.v1 and Edge.v2 are read-only - #39

Merged
petercorke merged 2 commits into
mainfrom
fix/edge-endpoints-read-only
Oct 11, 2026
Merged

petercorke merged 2 commits into
mainfrom
fix/edge-endpoints-read-only

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Edge.v1 and Edge.v2 were plain attributes, so e.v1 = None on an edge that was in a graph left it wedged: remove_edge and remove_vertex raised, incidence() hit an assert, and the edge could not be removed. Assigning one of them to another vertex left the edge disagreeing with the vertices' edge lists.

Only the library binds an edge to its vertices (the constructor, connect() and remove_edge()), so they are now read-only properties over private fields, set through one private method. Assigning raises AttributeError saying to use the constructor or connect() instead. An edge that is in a graph always has both of its ends.

Breaking change (1.0)

Code that assigned edge.v1 / edge.v2 now gets AttributeError. I audited RTB, MVTB, RVC3 and SMTB: nothing assigns an endpoint, and all three downstream Edge subclasses (MVTB Observation, RTB LatticeEdge and PGEdge) call super().__init__(v1, v2, ...).

Tests

tests/test_edge_endpoints.py: assignment is refused (to a vertex and to None), the graph is left untouched by the attempt, and the library can still bind, connect and remove.

🤖 Generated with Claude Code

petercorke and others added 2 commits October 12, 2026 09:19
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
They were plain attributes, so e.v1 = None on an edge that was in a graph left
it wedged: remove_edge and remove_vertex raised, incidence() hit an assert,
and the edge could not be removed. Assigning to one of them to another vertex
left the edge disagreeing with the vertices' edge lists.

Only the library binds an edge to its vertices -- the constructor, connect(),
and remove_edge() -- so they are now properties over private fields, set
through one method, and assigning raises AttributeError saying to use the
constructor or connect() instead. An edge that is in a graph always has both
of its ends.

The downstream Edge subclasses (MVTB Observation, RTB LatticeEdge and PGEdge)
all call super().__init__(v1, v2), and nothing in RTB, MVTB, RVC3 or
spatialmath assigns an endpoint.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 18 complexity · 1 duplication

Metric Results
Complexity 18
Duplication 1

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit 9ac0001 into main Oct 11, 2026
12 checks passed
@petercorke
petercorke deleted the fix/edge-endpoints-read-only branch October 11, 2026 23:21
@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.86%. Comparing base (f3e1e04) to head (d8f7911).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #39      +/-   ##
==========================================
+ Coverage   93.79%   93.86%   +0.07%     
==========================================
  Files           3        3              
  Lines        1063     1076      +13     
==========================================
+ Hits          997     1010      +13     
  Misses         66       66              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant