-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Preserve r-string prefix capitalization #1244
Copy link
Copy link
Labels
F: stringsRelated to our handling of stringsRelated to our handling of stringsS: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedThe changes in this design / enhancement issue have been accepted and can be implementedT: bugSomething isn't workingSomething isn't workingT: enhancementNew feature or requestNew feature or request
Metadata
Metadata
Assignees
Labels
F: stringsRelated to our handling of stringsRelated to our handling of stringsS: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedThe changes in this design / enhancement issue have been accepted and can be implementedT: bugSomething isn't workingSomething isn't workingT: enhancementNew feature or requestNew feature or request
The MagicPython syntax highlighter (and VS Code, Sublime Text and Atom which all use it) interprets upper (
R"foo") and lower case r-strings (r"bar") differently. The reason for this is explained in their readme:This is a neat feature, especially in cases with more involved string interpolation which are hard to read and easy to mess up without proper highlighting. As a simplified example:
Note that even GitHub syntax highlighting has this feature. This is what it looks like in VS Code:
Unfortunately, this feature becomes unusable in conjunction with
blacksinceblackautomatically lower cases all r-strings.Describe the solution you'd like
Either add an option to
pyproject.tomlto disable automatic lower casing and/or changeblack's default behavior to preserve string prefix casing. I prefer the latter.Additional context
This behavior was introduced in #198, apparently without being aware that some syntax highlighters treat the cases differently.