Skip to content

fix: deprecate adjacent()/vertices() properly instead of hard-breaking - #2

Merged
petercorke merged 1 commit into
mainfrom
deprecate/adjacent-to-neighbours
Aug 16, 2026
Merged

petercorke merged 1 commit into
mainfrom
deprecate/adjacent-to-neighbours

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

  • UVertex.adjacent() had been removed outright with no migration path -- renamed to neighbours()/neighbors() with zero deprecation phase, so any caller still using the old name got a bare AttributeError. Restored it as a thin wrapper: still calls neighbours() and returns its result, but now emits a DeprecationWarning first, giving callers a working upgrade path instead of an immediate break.
  • Also fixed the same underlying anti-pattern already present nearby in Edge.vertices(): it did raise DeprecationWarning(...), which aborts the call exactly like a missing method would (DeprecationWarning is just an Exception subclass when raised directly) -- no backward compatibility at all, and it never goes through the actual warnings machinery (no -W flag control, no filterwarnings support). Now uses warnings.warn(..., DeprecationWarning, stacklevel=2) and still returns self.endpoints, matching the same real deprecation pattern as adjacent() above.

Test plan

  • `tests/test_graph.py::TestUGraph::test_adjacent_deprecated` (new) -- `adjacent()` still returns the same result as `neighbours()`, wrapped in `assertWarns(DeprecationWarning)`
  • `tests/test_graph.py::TestUGraph::test_edge_vertices_deprecated` (new) -- `vertices()` still returns the same result as `endpoints`, wrapped in `assertWarns(DeprecationWarning)`
  • Full test suite: 34 passed, no regressions
  • Manually verified against RVC3-python's `app.ipynb` notebook (`g[1].adjacent()`), which was hitting the original hard-break

🤖 Generated with Claude Code

UVertex.adjacent() had been removed outright with no migration path --
renamed to neighbours()/neighbors() with zero deprecation phase, so any
caller still using the old name got a bare AttributeError. Restored it
as a thin wrapper: still calls neighbours() and returns its result, but
now emits a DeprecationWarning first, giving callers a working upgrade
path instead of an immediate break.

Also fixed the same underlying anti-pattern already present nearby in
Edge.vertices(): it did `raise DeprecationWarning(...)`, which aborts
the call exactly like a missing method would (DeprecationWarning is
just an Exception subclass when raised directly) -- no backward
compatibility at all, and it never goes through the actual warnings
machinery (no -W flag control, no filterwarnings support). Now uses
warnings.warn(..., DeprecationWarning, stacklevel=2) and still returns
self.endpoints, matching the same real deprecation pattern as
adjacent() above.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.28%. Comparing base (13582c4) to head (c29e3f3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #2      +/-   ##
==========================================
+ Coverage   81.88%   82.28%   +0.40%     
==========================================
  Files           2        2              
  Lines         712      717       +5     
==========================================
+ Hits          583      590       +7     
+ Misses        129      127       -2     

☔ 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.

@petercorke
petercorke merged commit 5b7dc36 into main Aug 16, 2026
8 checks passed
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