Skip to content

Commit 5ff0dd2

Browse files
authored
Merge pull request #2 from bswck/lazy-import-pyrepl-highlight
Highlight lazy imports in the new REPL
2 parents 5d6026a + c0c0d80 commit 5ff0dd2

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Lib/_pyrepl/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool:
270270
TI(T.NAME, string=s)
271271
):
272272
return not keyword.iskeyword(s)
273+
case (None | TI(T.NEWLINE) | TI(T.INDENT) | TI(T.DEDENT), TI(string="lazy"), TI(string="import")):
274+
return True
273275
case _:
274276
return False
275277

Lib/test/test_pyrepl/test_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,13 @@ def test_gen_colors_keyword_highlighting(self):
6868
("obj.list", [(".", "op")]),
6969
("obj.match", [(".", "op")]),
7070
("b. \\\n format", [(".", "op")]),
71+
("lazy", []),
72+
("lazy()", [('(', 'op'), (')', 'op')]),
7173
# highlights
7274
("set", [("set", "builtin")]),
7375
("list", [("list", "builtin")]),
7476
(" \n dict", [("dict", "builtin")]),
77+
(" lazy import", [("lazy", "soft_keyword"), ("import", "keyword")]),
7578
]
7679
for code, expected_highlights in cases:
7780
with self.subTest(code=code):

0 commit comments

Comments
 (0)