Add hasattr check for isatty on sys.stdout (#27)

* Add hasattr check for isatty on sys.stdout

* fix flake8 error

Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
This commit is contained in:
Matthew Peveler
2020-08-26 17:24:18 -04:00
committed by GitHub
parent 439c7fa380
commit 50d6cc85f8
+3 -1
View File
@@ -80,7 +80,9 @@ class ColoredString(object):
if self.always_color:
return c
elif sys.stdout.isatty() and not DISABLE_COLOR:
elif hasattr(sys.stdout, 'isatty') \
and sys.stdout.isatty() \
and not DISABLE_COLOR:
return c
else:
return self.s