-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ctx.color
is ignored in ClickException.show()
#2193
Milestone
Comments
If I am correct that the context is already closed while handling the exception then I guess it is not so easy to fix. In such a case, could you propose a WAR for that? Thanks! |
I'm at the PyCon sprints and can take on working on this |
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have tried to set
ctx.color = True
as suggested in #1090 in order to enable colour output in Gitlab CI. This worked out great for normalclick.secho
but unfortunately it does not work for output generated via raisingClickException
subclass. Essentially theecho
insideClickException.show()
ignoresctx.color
.After some digging, I am almost sure this is because the
get_current_context
returnsNone
, there is no context when exceptions are handled:click/src/click/globals.py
Line 63 in 49164fa
Test code
Test cases
python test.py
python test.py --ansi
python test.py &> test.log; cat test.log
python test.py --ansi &> test.log; cat test.log
Expected behaviour
In all cases except 3) there is a green
some output
and redsome error
in output.In 3) there is no colouring.
Actual behaviour
Everything is as expected except 4) where
some error
is not coloured.Environment
The text was updated successfully, but these errors were encountered: