Skip to content

Commit e34ad8b

Browse files
authored
Merge pull request #2923 from Textualize/fix-is-terminal
fix for is_terminal
2 parents 076e0d2 + bd4cffb commit e34ad8b

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [13.3.4] - 2023-04-12
9+
10+
### Fixed
11+
12+
- Fixed for `is_terminal` ignoring FORCE_COLOR https://github.com/Textualize/rich/pull/2923
13+
814
## [13.3.3] - 2023-02-27
915

1016
### Added
@@ -1930,6 +1936,8 @@ Major version bump for a breaking change to `Text.stylize signature`, which corr
19301936

19311937
- First official release, API still to be stabilized
19321938

1939+
[13.3.4]: https://github.com/textualize/rich/compare/v13.3.3...v13.3.4
1940+
[13.3.3]: https://github.com/textualize/rich/compare/v13.3.2...v13.3.3
19331941
[13.3.2]: https://github.com/textualize/rich/compare/v13.3.1...v13.3.2
19341942
[13.3.1]: https://github.com/textualize/rich/compare/v13.3.0...v13.3.1
19351943
[13.3.0]: https://github.com/textualize/rich/compare/v13.2.0...v13.3.0

rich/console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,7 @@ def is_terminal(self) -> bool:
952952
force_color = self._environ.get("FORCE_COLOR")
953953
if force_color is not None:
954954
self._force_terminal = True
955+
return True
955956

956957
isatty: Optional[Callable[[], bool]] = getattr(self.file, "isatty", None)
957958
try:
@@ -2000,7 +2001,6 @@ def _check_buffer(self) -> None:
20002001
self._record_buffer.extend(self._buffer[:])
20012002

20022003
if self._buffer_index == 0:
2003-
20042004
if self.is_jupyter: # pragma: no cover
20052005
from .jupyter import display
20062006

tests/test_console.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,3 +979,15 @@ def test_force_color_jupyter():
979979
file=io.StringIO(), _environ={"FORCE_COLOR": "1"}, force_jupyter=True
980980
)
981981
assert not console.is_terminal
982+
983+
984+
def test_force_color():
985+
console = Console(
986+
file=io.StringIO(),
987+
_environ={
988+
"FORCE_COLOR": "1",
989+
"TERM": "xterm-256color",
990+
"COLORTERM": "truecolor",
991+
},
992+
)
993+
assert console.color_system in ("truecolor", "windows")

0 commit comments

Comments
 (0)