diff --git a/discord/utils.py b/discord/utils.py index 9fe664caf..6d1e2ed17 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -1243,11 +1243,12 @@ def is_docker() -> bool: def stream_supports_colour(stream: Any) -> bool: + is_a_tty = hasattr(stream, 'isatty') and stream.isatty() + # Pycharm and Vscode support colour in their inbuilt editors if 'PYCHARM_HOSTED' in os.environ or os.environ.get('TERM_PROGRAM') == 'vscode': - return True + return is_a_tty - is_a_tty = hasattr(stream, 'isatty') and stream.isatty() if sys.platform != 'win32': # Docker does not consistently have a tty attached to it return is_a_tty or is_docker()