Repository navigation
Conversation
β¦efix T"..." t-strings added in Python 3.14 (PEP 750) were not normalized to t"..." by normalize_string_prefix. The function normalized Fβf, Bβb, and removed U/u, but omitted Tβt when t-string support was introduced in psf#4805. This caused T"..." to pass through unchanged instead of being downcased like all other normalizable string prefixes.
|
Tβt prefix normalization is now gated behind |
| .replace("U", "") | ||
| .replace("u", "") | ||
| ) | ||
| if mode is None or _is_preview_tstring_normalization(mode): |
There was a problem hiding this comment.
Can you inline the Preview.normalize_tstring_prefix in mode call instead of making a utility function?
|
|
||
|
|
||
| def normalize_string_prefix(s: str) -> str: | ||
| def normalize_string_prefix(s: str, mode: "Mode | None" = None) -> str: |
There was a problem hiding this comment.
I'd prefer for mode to be required, just so we don't accidentally forget it anywhere. Black's public API isn't considered stable, so it's not a breaking change.
|
|
||
|
|
||
| def _is_preview_tstring_normalization(mode: "Mode") -> bool: | ||
| from black.mode import Preview |
There was a problem hiding this comment.
Do we need this inline import? Why can't we just import black.mode normally?
|
@JSap0914 are you still updating this? |
|
Closing as stale. Feel free to open a new PR following the guidelines I set above. I'll also create a new issue for this so it may be picked up by someone else instead. |
Description
normalize_string_prefixis documented to "make all string prefixes lowercase", and it already normalisesFβfandBβb. However, when t-string support was added in #4805 theTβtnormalisation was accidentally omitted.Bug: Black leaves
T"..."unchanged instead of normalising it tot"...":Fix: Add a single
.replace("T", "t")step to the existing chain innormalize_string_prefix.Verification:
Checklist - did you ...
--previewstyle, following the stability policy?CHANGES.mdif necessary?