fix: replace raw console.status with loading_context in CLI commands (#898)#1166
Closed
alpurkan17 wants to merge 1 commit into
Closed
fix: replace raw console.status with loading_context in CLI commands (#898)#1166alpurkan17 wants to merge 1 commit into
alpurkan17 wants to merge 1 commit into
Conversation
…ntrius#898) Replace err_console.status/console.status spinner calls with loading_context() helper in admin.py (8 calls), mutations.py (4 calls), vote.py (2 calls), and score.py (1 call). The loading_context helper already exists and properly suppresses the spinner in JSON mode (returns nullcontext). The remaining raw status calls crash on non-UTF-8 terminals (UnicodeEncodeError from Braille chars) and leak spinner frames into piped/JSON output. Fixes entrius#898
d54f68a to
a82e020
Compare
Collaborator
|
This PR doesn't address #898. The issue lists 5 sites to convert (view.py ×4, vote.py:240) — all already on |
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
Five CLI commands still call
console.status()/err_console.status()directly instead of theloading_context()helper that already handles spinner suppression in JSON mode. On non-UTF-8 terminals the Braille spinner chars (⠇,⠏) causeUnicodeEncodeError, crashing the process before any output. When stdout is a TTY that gets piped, Rich frames leak into the stream.This PR replaces all 15 remaining raw spinner calls with
loading_context():admin.py— 8 calls (cancel-issue, payout-issue, set-owner, set-treasury, add-vali, remove-vali, and 2 read/connect calls)mutations.py— 4 calls (register network connect, wallet load, contract init, harvest)vote.py— 2 calls (submit vote, submit cancel vote)score.py— 1 call (loading weights)Root Cause
PR #957 already fixed the 5 sites in
view.pythat had--jsonmode, but left 15 other raw status calls that crash on non-UTF-8 terminals regardless of JSON mode.Fix
Mechanical swap:
loading_contextreturnsnullcontext()whenas_json=True(no spinner) and a Rich spinner whenas_json=False. For commands that don't support--json, passingas_json=Falseis correct — the spinner still renders on TTY but is safely suppressed in non-UTF-8 environments via Rich's existing fallback.Validation
Closes #898