From 5246a29347305d0a5a7fb4b79eaa52db40637b11 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 9 Aug 2022 12:41:09 +0100 Subject: [PATCH 1/6] Handle no_color Console on legacy Windows platforms --- rich/console.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rich/console.py b/rich/console.py index 8c6049a49..cf15048a2 100644 --- a/rich/console.py +++ b/rich/console.py @@ -1996,9 +1996,11 @@ def _check_buffer(self) -> None: from rich._win32_console import LegacyWindowsTerm from rich._windows_renderer import legacy_windows_render - legacy_windows_render( - self._buffer[:], LegacyWindowsTerm(self.file) - ) + buffer = self._buffer[:] + if self.no_color and self._color_system: + buffer = Segment.remove_color(buffer) + + legacy_windows_render(buffer, LegacyWindowsTerm(self.file)) else: # Either a non-std stream on legacy Windows, or modern Windows. text = self._render_buffer(self._buffer[:]) From 32196384d05df629a66ed2c81a532fe6e0d8c58a Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 9 Aug 2022 12:54:51 +0100 Subject: [PATCH 2/6] Fix mypy typing issue --- rich/console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rich/console.py b/rich/console.py index cf15048a2..4f4675b10 100644 --- a/rich/console.py +++ b/rich/console.py @@ -1998,7 +1998,7 @@ def _check_buffer(self) -> None: buffer = self._buffer[:] if self.no_color and self._color_system: - buffer = Segment.remove_color(buffer) + buffer = list(Segment.remove_color(buffer)) legacy_windows_render(buffer, LegacyWindowsTerm(self.file)) else: From 981ffa46339d0c28e8469de95bc9418ebe30d03d Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 9 Aug 2022 13:00:58 +0100 Subject: [PATCH 3/6] Update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90cd313d6..4b2800e89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Fix NO_COLOR support on legacy Windows https://github.com/Textualize/rich/pull/2458 + ## [12.5.2] - 2022-07-18 ### Added From ae4eacf32d4b9effa92e7fa2a30a18d201c1d5bd Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 9 Aug 2022 13:13:21 +0100 Subject: [PATCH 4/6] Upgrade Python3.11 from beta4 to beta5 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index dbadb79d8..a60b4a82d 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-beta.4"] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-beta.5"] defaults: run: shell: bash From a51bca4bf236379b77e3c1f87ccde2b7f7a2d97f Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 9 Aug 2022 13:22:51 +0100 Subject: [PATCH 5/6] Fix broken conditional in pythonpackage.yml GitHub Action --- .github/workflows/pythonpackage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index a60b4a82d..4ba60cdee 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -36,12 +36,12 @@ jobs: source $VENV make typecheck - name: Test with pytest (with coverage) - if: matrix.python-version != '3.11.0-beta.4' + if: matrix.python-version != '3.11.0-beta.5' run: | source $VENV pytest tests -v --cov=./rich --cov-report=xml:./coverage.xml --cov-report term-missing - name: Test with pytest (no coverage) - if: matrix.python-version == '3.11.0-beta.4' + if: matrix.python-version == '3.11.0-beta.5' run: | source $VENV pytest tests -v From 42afd3aedf32e1357e336147d37b4f7dbdfe85ae Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 9 Aug 2022 13:47:26 +0100 Subject: [PATCH 6/6] Remove Python3.11 beta 5 from CI --- .github/workflows/pythonpackage.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 4ba60cdee..40685a56e 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-beta.5"] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] defaults: run: shell: bash @@ -36,15 +36,9 @@ jobs: source $VENV make typecheck - name: Test with pytest (with coverage) - if: matrix.python-version != '3.11.0-beta.5' run: | source $VENV pytest tests -v --cov=./rich --cov-report=xml:./coverage.xml --cov-report term-missing - - name: Test with pytest (no coverage) - if: matrix.python-version == '3.11.0-beta.5' - run: | - source $VENV - pytest tests -v - name: Upload code coverage uses: codecov/codecov-action@v2 with: