From a9ebb52168d00b738ebc244504f864b97146c421 Mon Sep 17 00:00:00 2001 From: titagass <269501527+titagass@users.noreply.github.com> Date: Fri, 3 Apr 2026 07:55:20 +0000 Subject: [PATCH] fix: delegate isatty() to proxied file in FileProxy --- rich/file_proxy.py | 3 +++ tests/test_file_proxy.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/rich/file_proxy.py b/rich/file_proxy.py index 4b0b0da6c2..e32523bd6b 100644 --- a/rich/file_proxy.py +++ b/rich/file_proxy.py @@ -55,3 +55,6 @@ def flush(self) -> None: def fileno(self) -> int: return self.__file.fileno() + + def isatty(self) -> bool: + return self.__file.isatty() diff --git a/tests/test_file_proxy.py b/tests/test_file_proxy.py index 2ec4d789e3..ff23493d14 100644 --- a/tests/test_file_proxy.py +++ b/tests/test_file_proxy.py @@ -35,3 +35,10 @@ def test_new_lines(): assert file.getvalue() == "-\n" file_proxy.flush() assert file.getvalue() == "-\n-\n" + + +def test_isatty_delegates_to_proxied_file(): + file = io.StringIO() + console = Console(file=file) + file_proxy = FileProxy(console, file) + assert file_proxy.isatty() == file.isatty()