Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
`from x import ( # fmt: skip`) when a standalone comment is among the bracket's
contents: the whole statement is now preserved instead of being reformatted (and
previously crashing) (#5161)
- Fix `normalize_string_prefix` not lowercasing the uppercase `T` prefix of
t-strings (e.g. `T"..."` was left unchanged instead of being normalized to
`t"..."`) (#XXXX)

### Preview style

Expand Down
1 change: 1 addition & 0 deletions src/black/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def normalize_string_prefix(s: str) -> str:
new_prefix = (
orig_prefix.replace("F", "f")
.replace("B", "b")
.replace("T", "t")
Comment thread
cobaltt7 marked this conversation as resolved.
Outdated
.replace("U", "")
.replace("u", "")
)
Expand Down
10 changes: 10 additions & 0 deletions tests/data/cases/pep_750.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
{1}_cte AS ()'''}
'''

# Uppercase T prefix is normalized to lowercase t
x = T"bar {1 + 1}"
x = T'bar {1 + 1}'
rT'\{{\}}'

# output
x = t"foo"
x = t"foo {{ {2 + 2}bar {{ baz"
Expand Down Expand Up @@ -81,3 +86,8 @@
WITH {f'''
{1}_cte AS ()'''}
"""

# Uppercase T prefix is normalized to lowercase t
x = t"bar {1 + 1}"
x = t"bar {1 + 1}"
rt"\{{\}}"