Skip to content

fix: rtbtool's %precision line spuriously echoes its own return value - #592

Open
petercorke wants to merge 1 commit into
mainfrom
fix/rtbtool-precision-echo
Open

fix: rtbtool's %precision line spuriously echoes its own return value#592
petercorke wants to merge 1 commit into
mainfrom
fix/rtbtool-precision-echo

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

  • rtbtool's default startup exec_lines end with a bare %precision %.3g as the last statement. IPython auto-displays the last bare-expression result by default (independent of --showassign), so every default rtbtool session prints a spurious Out[1]: '%.3g' right before the first real prompt.
  • Fixed by wrapping the magic call in get_ipython().run_line_magic(...), assigning the result, and printing it explicitly with a clear label — so the line's last statement is a print() call, which is never auto-displayed.

Found while doing the equivalent fix in RVC3-python's rvctool (same class of bug, same root cause) — mvtbtool has a related but currently-latent version of this (only manifests with --showassign), tracked separately.

Test plan

  • rtbtool --no-banner (default startup) — confirmed no more Out[1]: '%.3g', shows Default numeric formatting: %.3g instead
  • pytest tests/test_bin.py — all 7 pass

The default startup exec_lines included a bare "%precision %.3g" as
the last statement, so it exits started IPython sessions and printed
Out[1]: '%.3g' immediately before the first real prompt -- the magic's
return value getting auto-displayed under normal IPython semantics
(bare expressions display by default, independent of --showassign).
Wrap it in run_line_magic() and print the result explicitly instead,
so the last statement is a print() call (never auto-displayed) rather
than a bare expression.
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (34755c8) to head (c8dac8c).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #592   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        142     142           
  Lines      13882   13882           
=====================================
  Misses     13882   13882           

☔ 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