gh-138318, PyREPL: builtins should not be highlighted when used as attribute names#138319
Conversation
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
sobolevn
left a comment
There was a problem hiding this comment.
I would actually say that the current behavior is more useful, since it allows users to see that they are typing in a keyword name and that there will be a syntax error because of that.
I am -1 on this change, sorry :(
not total agree before this patch I tried |
|
I am not against to stop highlighting |
That's their own choices. But writing the keyword and hitting enter would anyway raise a SyntaxError so I think it's better that users know that they are writing a keyword and that they can't do that. But I agree that the |
|
ghci
a.set and a.list the list highligt in VS Code is strange, I wonder it is the same in repl |
|
Nonetheless, while two core devs opposed changing the behavior for keywords, I'm willing to support a change of behavior when it comes to built-ins used as attributes. I think it makes sense not to highlight them. |
thank you |
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
|
now only not highlight the buildin words |
fixed that, thank you. |
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Misc/NEWS.d/next/Core_and_Builtins/2025-09-01-16-09-02.gh-issue-138318.t-WEN5.rst
Outdated
Show resolved
Hide resolved
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Misc/NEWS.d/next/Core_and_Builtins/2025-09-01-16-09-02.gh-issue-138318.t-WEN5.rst
Outdated
Show resolved
Hide resolved
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Misc/NEWS.d/next/Core_and_Builtins/2025-09-01-16-09-02.gh-issue-138318.t-WEN5.rst
Outdated
Show resolved
Hide resolved
Signed-off-by: yihong0618 <zouzou0208@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
picnixz
left a comment
There was a problem hiding this comment.
I'll let REPL experts have a look in addition but thank you for the fix!
Thank you for your kindess review and @sobolevn learned a lot from this! |
pablogsal
left a comment
There was a problem hiding this comment.
This looks good to me! Thanks for the PR @yihong0618
|
Thanks @yihong0618 for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
… as attribute names (pythonGH-138319) (cherry picked from commit 7a3bca5) Co-authored-by: yihong <zouzou0208@gmail.com>
|
GH-138654 is a backport of this pull request to the 3.14 branch. |
…en used as attribute names (pythonGH-138319) (python#138654) pythongh-138318, PyREPL: builtins should not be highlighted when used as attribute names (pythonGH-138319) (cherry picked from commit 7a3bca5) Co-authored-by: yihong <zouzou0208@gmail.com>
… as attribute names (python#138319)



We remove REPL highlighting when a builtin name is used as an attribute name. Keywords will still be highlighted as they can never be used as valid attribute names.
Previous discussion about keywords
as diff
before the patch:

after the patch:
after the disscuss