gh-151471: colorizer the type when it start a statement - #151700
Conversation
The `news` will be added soon. I put `type_softkw` before `builtin` because of the afraid that `builtin` may cover the `type_softkw` in re. Now there is no test.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
The pattern works for the cases I tried, including type = type(1) and type(x) staying builtins. Two things before merging:
- The lookahead
[A-Za-z_]rejects non-ASCII names, sotype Точка = intis not colored. Use[^\W\d](an identifier start) instead. - Please add a NEWS entry under
Misc/NEWS.d/next/IDLE/(blurbor blurb-it), and a test: addtype Point = tuple[float, float]andtype = type(1)tosourceintest_colorizer.pyand the expected tags for those lines totest_recolorize_main— note the line numbers are those of the dedentedsourcestring, so currently 32 and 33.
|
I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @serhiy-storchaka: please review the changes made to this pull request. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Thanks! Works for me, including non-ASCII names, indented statements, and type = type(1) / type(x) staying builtins. One optional refinement and a NEWS wording suggestion inline. After merging I will close #155958 as a duplicate.
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…03.rst Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
Serhiy, your last two change requests have been made. Do you want to merge (and close alt PR) or shall I? I added backports. |
|
Thanks @Locked-chess-official for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
Sorry, @Locked-chess-official and @serhiy-storchaka, I could not cleanly backport this to |
|
Sorry, @Locked-chess-official and @serhiy-storchaka, I could not cleanly backport this to |
|
GH-157991 is a backport of this pull request to the 3.15 branch. |
|
GH-157992 is a backport of this pull request to the 3.14 branch. |
|
GH-157993 is a backport of this pull request to the 3.13 branch. |
GH-157993) `type` is now colored as a keyword when it starts a statement and is followed by a name, as in `type Point = tuple[float, float]`. It stays a builtin elsewhere, for example in `type = type(1)`, `type(x)` or `type in (int, str)`. (cherry picked from commit 68ed7a5) Co-authored-by: Locked-chess-official <13140752715@163.com>
GH-157992) `type` is now colored as a keyword when it starts a statement and is followed by a name, as in `type Point = tuple[float, float]`. It stays a builtin elsewhere, for example in `type = type(1)`, `type(x)` or `type in (int, str)`. (cherry picked from commit 68ed7a5) Co-authored-by: Locked-chess-official <13140752715@163.com>
The
newswill be added.I put
type_softkwbeforebuiltinbecause of the afraid thatbuiltinmay cover thetype_softkwin re.Now there is no test. It will also be added after it passed on py PC.
typeas a soft keyword when it begins a statememt #151471