Skip to content

refactor: make graph constructor arguments keyword-only - #41

Merged
petercorke merged 2 commits into
mainfrom
refactor/keyword-only-graph-constructor
Oct 11, 2026
Merged

petercorke merged 2 commits into
mainfrom
refactor/keyword-only-graph-constructor

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Every BaseGraph / UGraph / DGraph constructor argument is now keyword-only.

In 0.6.5 the first positional parameter (arg) was accepted and silently ignored, so UGraph(6) looked as though it set a dimension but did nothing. With the current signature the 6 would land in metric. Making the arguments keyword-only turns the mistake into a clear TypeError.

Breaking change (1.0)

UGraph(6), UGraph("L2") etc. now raise TypeError; use UGraph(dim=6), UGraph(metric="L2").

I checked the downstream code. RTB calls UGraph(), UGraph(verbose=...), DGraph(metric="SE2") only. MVTB BundleAdjust called pgraph.UGraph(6), which is fixed independently in petercorke/machinevision-toolbox-python#127 (it uses UGraph(), since views are 6D and landmarks 3D, so dim=6 would be wrong), and works on both 0.6.5 and 1.0.

Tests

tests/test_constructor_keywords.py: positional arguments are rejected for both graph kinds, keywords accepted, no-argument form still works.

🤖 Generated with Claude Code

In 0.6.5 the first positional argument was accepted and ignored, so
UGraph(6) looked as though it set a dimension but did nothing.  With the
current signature it would land in metric.  Making every argument
keyword-only turns UGraph(6) into a clear TypeError.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@petercorke
petercorke force-pushed the refactor/keyword-only-graph-constructor branch from 5e62b9c to 31fb30d Compare October 11, 2026 23:26
@codacy-production

codacy-production Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 complexity · 0 duplication

Metric Results
Complexity 4
Duplication 0

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.

@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 94.60%. Comparing base (e68d477) to head (8c62dd2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #41   +/-   ##
=======================================
  Coverage   94.60%   94.60%           
=======================================
  Files           3        3           
  Lines        1205     1205           
=======================================
  Hits         1140     1140           
  Misses         65       65           

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

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@petercorke
petercorke merged commit 6d07258 into main Oct 11, 2026
14 checks passed
@petercorke
petercorke deleted the refactor/keyword-only-graph-constructor branch October 11, 2026 23:33
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