From 0e952c3cb760168f9e9af626b9a8b2c4d8188f6a Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sun, 12 Apr 2026 11:05:57 +0700 Subject: [PATCH 1/2] proxy isatty --- rich/file_proxy.py | 3 +++ tests/test_file_proxy.py | 17 +++++++++++++++++ 2 files changed, 20 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..c73b23fe17 100644 --- a/tests/test_file_proxy.py +++ b/tests/test_file_proxy.py @@ -35,3 +35,20 @@ def test_new_lines(): assert file.getvalue() == "-\n" file_proxy.flush() assert file.getvalue() == "-\n-\n" + + +def test_isatty(): + """Check isatty is proxied + + Regression test for https://github.com/Textualize/rich/issues/4041 + + """ + + class TTYFile: + def isatty(self) -> bool: + return True + + file = TTYFile() + console = Console() + file_proxy = FileProxy(console, file) + assert file_proxy.isatty() From 494b795031782c694297d2db78bd04fb8c82f590 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sun, 12 Apr 2026 11:06:55 +0700 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4c27de5f6..d2e7906004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed empty print ignoring the `end` parameter - Fixed `Text.from_ansi` removing newlines https://github.com/Textualize/rich/pull/4076 +- Fixed `FileProxy.isatty` not proxying https://github.com/Textualize/rich/pull/4077 ## [14.3.4] - 2026-04-11