posit-dev / positron

Positron, a next-generation data science IDE
Other
1.03k stars 23 forks source link

Python: Not needed syntax highlighting for string literals #3387

Open jonvanausdeln opened 3 weeks ago

jonvanausdeln commented 3 weeks ago

Currently Positron and VSCode still add syntax highlighting to string literal:

image

In this case, bar is a string literal and will gets automatically escaped correctly by python. I would like to see it not highlight the missing escapes, similiar to how PyCharm does it.

image

juliasilge commented 2 weeks ago

This probably would involve contributing to Jedi (?) upstream.

seeM commented 2 weeks ago

This is defined in the Python grammar: https://github.com/posit-dev/positron/blob/cae259ea2ddd32c5f5eb7c8bc913adfe346842c9/extensions/python/syntaxes/MagicPython.tmLanguage.json#L1.

Which is vendored from this repo: https://github.com/MagicStack/MagicPython.

I see there's an issue there for this case: https://github.com/MagicStack/MagicPython/issues/259.

This is apparently a feature 😅 https://github.com/MagicStack/MagicPython/issues/114#issuecomment-349115524:

This is a feature.

foo = r'\nregexp'  # this is parsed as a "regexp-string"
bar = R'\nregexp'  # this is parsed as a raw string
image