You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] ClickException message without color would be helpful #2419
Similar to how some runtime environments don't support colors, it may be helpful to programmers that the non-colorized rendering of the ClickException message was available... something I was thinking when encountering and working around #2193.
Color shouldn't matter, nor should creating subclasses be necessary for verifying that the correct user-facing ClickException was raised with a certain message, for example in a test:
"""Tests for ClickException and exception handling."""importclickdeftest_exception_message_no_color():
"""Base Exception message should be plain text."""exception=click.ClickException(click.style('red', fg='red') +' text')
assert'red text'instr(exception) # fails currently
I'd think that __str__, and the possibly the message property too, should be rendered as plain text. I do have a simple StringIO patch that works, as well as just creating a subclass for my code if click is unpatched.
changed the title [-]`ClickException` message without color would be helpful[/-][+][Feature] `ClickException` message without color would be helpful[/+]on Jan 5, 2025
Activity
[-]`ClickException` message without color would be helpful[/-][+][Feature] `ClickException` message without color would be helpful[/+]kdeldycke commentedon Oct 29, 2026
Relates to: #944
kdeldycke commentedon Oct 29, 2026
Closing this as Click already does this: to get the plain text of a styled message, call
click.unstyle().Click's own test suite cover this at:
click/tests/test_testing.py
Lines 229 to 246 in 8b19813
kdeldycke commentedon Oct 29, 2026
As a definitive proof, I added some more tests in #3899