fix: use rprint instead of click.echo for Rich markup error messages#1437
Open
frankgoldfish wants to merge 1 commit intopython-semantic-release:masterfrom
Open
Conversation
When `semantic-release version` is run with `--strict` and no new commits have been found, the error message containing Rich markup ([bold orange1]...) was passed to `click.echo()` instead of `rprint()`, causing the markup tags to be printed literally rather than rendered as formatted text. The non-strict path correctly used `rprint()`. This commit makes the strict path consistent by also using `rprint(file=sys.stderr)` to render the markup before writing to stderr. Fixes python-semantic-release#1423
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.
Problem
When running
semantic-release --verbose --noop --strict versionwith no new commits since the last release, the error message is printed with literal Rich markup tags instead of formatted text:Actual:
[bold orange1]No release will be made, ...Expected: Formatted bold orange message
Root cause
In
cli/commands/version.py, theif opts.strictbranch usesclick.echo(err_msg, err=True)which doesn't process Rich markup. The non-strict path correctly usesrprint(err_msg).Fix
Replace
click.echo(err_msg, err=True)withrprint(err_msg, file=sys.stderr)so both paths render Rich markup consistently.Fixes #1423