]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-145239: Colorize `case +` in the REPL (#150979)
authorBartosz Sławecki <bartosz@ilikepython.com>
Wed, 10 Jun 2026 06:36:50 +0000 (08:36 +0200)
committerGitHub <noreply@github.com>
Wed, 10 Jun 2026 06:36:50 +0000 (09:36 +0300)
Lib/_pyrepl/utils.py
Lib/test/test_pyrepl/test_utils.py

index b50426c31ead53a8015124943b061ed168289494..f2837a1b8eb95e7685d05bcf4c9e28e6bd6d1fe0 100644 (file)
@@ -274,7 +274,7 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool:
             None | TI(T.NEWLINE) | TI(T.INDENT) | TI(T.DEDENT) | TI(string=":"),
             TI(string="case"),
             TI(T.NUMBER | T.STRING | T.FSTRING_START | T.TSTRING_START)
-            | TI(T.OP, string="(" | "*" | "-" | "[" | "{")
+            | TI(T.OP, string="(" | "*" | "-" | "+" | "[" | "{")
         ):
             return True
         case (
index 3c55b6bdaeee9e85abcd4f204876bd5968880d05..0b873d32b62b5d26938dc7b162667c9dfac628c4 100644 (file)
@@ -125,6 +125,14 @@ class TestUtils(TestCase):
                     ("import", "keyword"),
                 ],
             ),
+            (
+                "case +1",
+                [
+                    ("case", "soft_keyword"),
+                    ("+", "op"),
+                    ("1", "number"),
+                ],
+            ),
         ]
         for code, expected_highlights in cases:
             with self.subTest(code=code):