-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python syntax file, support f-string #14033
Comments
|
Modified, hardcoded several layers, maybe enough |
Thanks. Could you please create a PR?
You can add the Ping @zvezdan |
I cannot add it to its own contains list, it should only take effect on the right side of the colon, and the expression needs to be highlighted on the left side |
@A4-Tacks I found four emails from you in the spam quarantine of my email provider because they were ranked as spam at high-level of probability, due to the following facts:
Each of these issues individually perhaps wouldn't be a problem, but taken together they resulted in your email messages being quarantined by my provider. I review quarantined messages once a week and I see them now. I allowed them to be delivered and carefully opened them (because I didn't trust them either) as raw messages, copied the base64 encoded content of the attachment into a file and then decoded it into an output file. It is indeed the patch similar to the one you have here. As you can see, I did not ignore your messages, but, rather, you caused the issue by your choice to send the messages as shown above. Lessons learned:
|
Thank you both @dkearns and @A4-Tacks! I'm currently testing this change, but also a few other options that I worked on and some other people sent. Some of the options are whether the bytes should be treated separately from strings, allowing for separate highlight coloring for people who prefer that, etc. This patch/issue is not making that distinction. Also, getting the In the meantime, I'm inclined to send a simpler PR that would just support f-strings correctly without trying to do any interpretation inside them. That would resolve some other already open issues, as well as partially covering this one. Then, I am testing a setting similar to In any case, I am working on this change and will incorporate all valid ideas including the ones from this issue and the corresponding patch. Thank you again and I'll keep you posted about the results of my testing soon. |
I had a quick attempt at this on the back of @A4-Tacks' PR. This patch allows for replacement fields in the format spec and avoids premature termination of the expression by spurious matches for the conversion and format spec delimiters. IIUC, the following are correctly matched: # Lib/fractions.py
digits = f"{significand:0{point_pos + 1}d}"
# Lib/test/test_fstring.py
self.assertEqual(f"sadsd {1 + 1 = :{1 + 1:1d}f}", "sadsd 1 + 1 = 2.000000")
# example from PEP - 701
f'Useless use of lambdas: { (lambda x: x*2) }' @zvezdan and @A4-Tacks, this is just intended as a proof-of-concept but if you think this is worth pursuing I can make a PR for consideration as a possible alternative to #14048. Edit: patch removed in favour of #14057 |
Why is the # Lib/fractions.py
digits = f"{significand:0{point_pos + 1}d}"
# Lib/test/test_fstring.py
self.assertEqual(f"sadsd {1 + 1 = :{1 + 1:1d}f}", "sadsd 1 + 1 = 2.000000")
# example from PEP - 701
f'Useless use of lambdas: { (lambda x: x*2) }'
def foo() -> None:
pass |
Sorry, I only tested against plain f-strings and overlooked the use of
@zvezdan, this use of Thanks for testing it out. |
@dkearns The places where However, the PR associated with this issue is trying to do two things: add f-string support and change a definition of strings to include There are other contributions and options that I'm looking into. Some of them prefer Give me a couple of days to prepare the changes please. Then we can start closing the outstanding issues and PRs as we commit them. Again, I truly appreciate all the contributions and ideas for improvements from all of you! |
Sure, I just posted my PR for discussion purposes. Feel free to take as much or as little of it as you like. |
Vim syntax file for Python, with support for f-string added
have contacted the maintainer zpetkovic@acm.org But there seems to be no response
python.vim.patch
The text was updated successfully, but these errors were encountered: