Remove redundant _color_supported() check.#6363
Merged
sawa3030 merged 6 commits intooptuna:masterfrom Dec 11, 2025
Merged
Conversation
Member
Author
|
I previously submitted the pull request #4376 to support non-tty devices with no color. I also introduced the |
NO_COLOR check._color_supported() check.
f797f5e to
bdb146e
Compare
Member
|
@sawa3030 Could you review this PR? |
sawa3030
approved these changes
Dec 11, 2025
Collaborator
sawa3030
left a comment
There was a problem hiding this comment.
LGTM. I have tested this change locally and confirmed it works as expected
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.
Motivation
The logging module
colorlogalready supports theNO_COLORenvironment variable since https://github.com/borntyping/python-colorlog/releases/tag/v6.0.0-alpha.2. Therefore, checking and switching the Formatter in Optuna code is unnecessary.Additionally,
colorlogsupports theFORCE_COLORoption, which forces colored outputs regardless of the environment. This is particularly useful when running Optuna in GitHub CI or other environments that don’t have a tty device but support colored outputs. However, in the current code, when the user provides theFORCE_COLORenvironment variable, Optuna ignores it, resulting in colorless output.Description of the changes
_color_supported()function since thecolorlogmodule itself can handle it.