From 9cd5b40bc873f78c382f9440ca9650f1773f53ec Mon Sep 17 00:00:00 2001 From: johnslavik Date: Fri, 12 Jun 2026 09:13:05 +0200 Subject: [PATCH 1/3] Colorize `match +` and `match -` in the REPL --- Lib/_pyrepl/utils.py | 2 +- Lib/test/test_pyrepl/test_utils.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Lib/_pyrepl/utils.py b/Lib/_pyrepl/utils.py index f2837a1b8eb95e..230dae35af665a 100644 --- a/Lib/_pyrepl/utils.py +++ b/Lib/_pyrepl/utils.py @@ -259,7 +259,7 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool: None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"), TI(string="match"), TI(T.NUMBER | T.STRING | T.FSTRING_START | T.TSTRING_START) - | TI(T.OP, string="(" | "*" | "[" | "{" | "~" | "...") + | TI(T.OP, string="(" | "*" | "-" | "+" | "[" | "{" | "~" | "...") ): return True case ( diff --git a/Lib/test/test_pyrepl/test_utils.py b/Lib/test/test_pyrepl/test_utils.py index 0b873d32b62b5d..ebbd06213c69af 100644 --- a/Lib/test/test_pyrepl/test_utils.py +++ b/Lib/test/test_pyrepl/test_utils.py @@ -133,6 +133,22 @@ def test_gen_colors_keyword_highlighting(self): ("1", "number"), ], ), + ( + "match +1", + [ + ("match", "soft_keyword"), + ("+", "op"), + ("1", "number"), + ], + ), + ( + "match -1", + [ + ("match", "soft_keyword"), + ("-", "op"), + ("1", "number"), + ], + ), ] for code, expected_highlights in cases: with self.subTest(code=code): From 637a06ae8edee1cd46ec1f0deac8db9a11ed29fc Mon Sep 17 00:00:00 2001 From: johnslavik Date: Fri, 12 Jun 2026 09:20:28 +0200 Subject: [PATCH 2/3] Add NEWS entry for gh-151390 --- .../Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst diff --git a/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst b/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst new file mode 100644 index 00000000000000..9f8b3bc8bf0fe2 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst @@ -0,0 +1,2 @@ +Fix the :term:`REPL` not colorizing ``match`` as a soft keyword when followed +by a unary ``+`` or ``-`` operator. Patch by Bartosz Sławecki. From 80b0949b40f17a515ee0a4b71f2f723b5a0e37d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20S=C5=82awecki?= Date: Sun, 14 Jun 2026 06:14:00 +0200 Subject: [PATCH 3/3] Reword news entry --- .../Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst b/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst index 9f8b3bc8bf0fe2..ff8de30599c6ad 100644 --- a/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst +++ b/Misc/NEWS.d/next/Library/2026-06-12-07-20-08.gh-issue-151390.CmYN9EeJ.rst @@ -1,2 +1 @@ -Fix the :term:`REPL` not colorizing ``match`` as a soft keyword when followed -by a unary ``+`` or ``-`` operator. Patch by Bartosz Sławecki. +Colorize ``match`` in the :term:`REPL` when followed by a unary ``+`` or ``-`` operator. Patch by Bartosz Sławecki.