fix: mvtbtool's %precision line spuriously echoes with --showassign - #79
Merged
Conversation
"_precision = %precision %.3g;" relied on the trailing ';' suppressing output, but IPython's magic-line parsing swallows the whole rest of the line -- including the ';' -- into %precision's own argument string, so it never functions as a suppression marker. This stayed latent by default (assignments aren't auto-displayed under the default ast_node_interactivity), but surfaces the moment --showassign is passed (same class of bug just fixed in rtbtool, and originally found in RVC3-python's rvctool): Out[1]: '%.3g;' printed right before the first real prompt. Wrap the magic call in run_line_magic() and print the result explicitly instead, so the last statement is a print() call, which is never auto-displayed regardless of ast_node_interactivity.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
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.
4 tasks
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
"_precision = %precision %.3g;"relied on the trailing;to suppress output, but IPython's magic-line parsing swallows the entire rest of the line — including the;— into%precision's own argument string, so it never actually functions as a suppression marker.ast_node_interactivity), but surfaces the moment--showassignis passed:Out[1]: '%.3g;'prints right before the first real prompt.rtbtool(fix: rtbtool's %precision line spuriously echoes its own return value robotics-toolbox-python#592), originally found while doing the equivalent fix in RVC3-python'srvctool.get_ipython().run_line_magic(...)and printing the result explicitly, so the line's last statement is aprint()call — never auto-displayed regardless ofast_node_interactivity.Test plan
mvtbtool(default) — confirmed clean, showsDefault numeric formatting: %.3gmvtbtool --showassign— confirmed clean too (this was the case that actually triggered the bug before)pytest tests/test_bin.py— 6 passed, 3 skipped (optional deps not installed)