You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IDLE - colorize type as a soft keyword when it begins a statememt #151471
Marking as easy, it's not quite trivial but I think a reasonable start. It will require writing a regex for the soft keyword, but it's not a terribly complicated one.
changed the title [-]Wrong colorize for soft keyword `type` in IDLE[/-][+]IDLE - colorize `type` as a soft keyword when it begins a statememt[/+]on Jun 14, 2026
I missed this syntax addition in 3.12. Soft keywords can sometimes be a bit nasty. All keywords and builtins, including new ones, are automatically recognized, whereas each soft keyword needs custom additions to both colorizer.py and test_colorizer.py*. A test that would currently fail in test_colorizer.ColorDelegatorTest is that the class has a 'test_soft...' test for each soft keyword other than '' in keyword.softkwlist. (EDIT: '' is included with 'case _')
Each file needs additions in about 3 places. I should add a comment to each. 'lazy' needs to be added to 'source' in the test.
The statement syntax for 'type' is most similar to that of 'lazy'. The re for identifiers is currently buried in the idprog definition, but should be separately defined before make_pat.
@robsdedude If you want comments on an incomplete patch, post it and mark it as a draft.
After reading #151390, I discovered that IDLE colorizes beginning-of-line 'match' and only uncolorizes it when followed by something identified as 'wrong', like a keyword or certain chars such as =. REPL does not colorize it until followed by something right. Either could be considered correct; I prefer the immediate coloring of initial 'match' as 'likely a keyword'. But IDLE does not always uncolorize when it should. For instance, match + remains colored because + could be valid, as in match +1. But IDLE stops there and also does not uncolorize on +=. case in handled similarly differently.
Like the REPL, IDLE does not colorize 'lazy' until confirmed as a keyword by 'import' or 'from'. type <identifier> should do the same, although the simple re for identifier is only approximate.
I've not been able to work on it this week as written above, but early next week I'll pick it up. And given the GH issue is still open and nobody commented or linked a PR, I guess it's not fixed. Unless in the somewhat unlikely event that it got fixed as a side-effect of another PR.
Activity
StanFromIreland commentedon Jun 14, 2026
Marking as easy, it's not quite trivial but I think a reasonable start. It will require writing a regex for the soft keyword, but it's not a terribly complicated one.
Maybe @robsdedude is interested in this?
robsdedude commentedon Jun 14, 2026
Thanks for the ping. I'm travelling this week without a laptop. If the issue still open next week I'd love to work on it!
omkar-334 commentedon Jun 14, 2026
hi, can I work on this
StanFromIreland commentedon Jun 14, 2026
Hi @omkar-334, I'm sorry but this issue already has someone assigned.
[-]Wrong colorize for soft keyword `type` in IDLE[/-][+]IDLE - colorize `type` as a soft keyword when it begins a statememt[/+]terryjreedy commentedon Jun 14, 2026
I missed this syntax addition in 3.12. Soft keywords can sometimes be a bit nasty. All keywords and builtins, including new ones, are automatically recognized, whereas each soft keyword needs custom additions to both colorizer.py and test_colorizer.py*. A test that would currently fail in test_colorizer.ColorDelegatorTest is that the class has a 'test_soft...' test for each soft keyword other than '' in keyword.softkwlist. (EDIT: '' is included with 'case _')
The statement syntax for 'type' is most similar to that of 'lazy'. The re for identifiers is currently buried in the idprog definition, but should be separately defined before make_pat.
@robsdedude If you want comments on an incomplete patch, post it and mark it as a draft.
terryjreedy commentedon Jun 14, 2026
After reading #151390, I discovered that IDLE colorizes beginning-of-line 'match' and only uncolorizes it when followed by something identified as 'wrong', like a keyword or certain chars such as
=. REPL does not colorize it until followed by something right. Either could be considered correct; I prefer the immediate coloring of initial 'match' as 'likely a keyword'. But IDLE does not always uncolorize when it should. For instance,match +remains colored because+could be valid, as inmatch +1. But IDLE stops there and also does not uncolorize on+=.casein handled similarly differently.Like the REPL, IDLE does not colorize 'lazy' until confirmed as a keyword by 'import' or 'from'.
type <identifier>should do the same, although the simple re for identifier is only approximate.Santhosh-I commentedon Jun 18, 2026
Hi, Is this Bug fixed...
robsdedude commentedon Jun 19, 2026
I've not been able to work on it this week as written above, but early next week I'll pick it up. And given the GH issue is still open and nobody commented or linked a PR, I guess it's not fixed. Unless in the somewhat unlikely event that it got fixed as a side-effect of another PR.
arshalaromal commentedon Jul 19, 2026
@robsdedude are you still working on this?
robsdedude commentedon Jul 19, 2026
No, I didn't start after I saw that @Locked-chess-official had already opened a PR (see link at the bottom of the issue).
gh-151471: Colorize the soft keyword `type` in IDLE (GH-151700)
[3.13] gh-151471: Colorize the soft keyword `type` in IDLE (GH-151700) (
[3.14] gh-151471: Colorize the soft keyword `type` in IDLE (GH-151700) (
[3.15] gh-151471: Colorize the soft keyword `type` in IDLE (GH-151700) (