Skip to content

Commit 9cd5b40

Browse files
committed
Colorize match + and match - in the REPL
1 parent c375992 commit 9cd5b40

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

Lib/_pyrepl/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool:
259259
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
260260
TI(string="match"),
261261
TI(T.NUMBER | T.STRING | T.FSTRING_START | T.TSTRING_START)
262-
| TI(T.OP, string="(" | "*" | "[" | "{" | "~" | "...")
262+
| TI(T.OP, string="(" | "*" | "-" | "+" | "[" | "{" | "~" | "...")
263263
):
264264
return True
265265
case (

Lib/test/test_pyrepl/test_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,22 @@ def test_gen_colors_keyword_highlighting(self):
133133
("1", "number"),
134134
],
135135
),
136+
(
137+
"match +1",
138+
[
139+
("match", "soft_keyword"),
140+
("+", "op"),
141+
("1", "number"),
142+
],
143+
),
144+
(
145+
"match -1",
146+
[
147+
("match", "soft_keyword"),
148+
("-", "op"),
149+
("1", "number"),
150+
],
151+
),
136152
]
137153
for code, expected_highlights in cases:
138154
with self.subTest(code=code):

0 commit comments

Comments
 (0)