Fix implicit concatenation of t-string literals with str or bytes - #11635
Open
Henry Su (hsusul) wants to merge 1 commit into
Open
Fix implicit concatenation of t-string literals with str or bytes#11635Henry Su (hsusul) wants to merge 1 commit into
Henry Su (hsusul) wants to merge 1 commit into
Conversation
PEP 750 and CPython 3.14 reject mixing t-string literals with string or bytes literals. Report that mix instead of inferring Template.
Collaborator
|
🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR. |
| t5 = "" t"x" | ||
|
|
||
| # This should generate an error. | ||
| t6 = t"x" "y" |
Collaborator
There was a problem hiding this comment.
Warning · Non-blocking recommendation
The tests only contribute to an aggregate diagnostic count and do not verify the new Unknown recovery type. Add reveal_type coverage for at least one mixed expression so a regression to Template inference cannot pass.
[verified]
Collaborator
|
Non-blocking follow-up: mirror this validation in Pylance's |
Rich Chiodo (rchiodo)
approved these changes
Aug 13, 2026
Rich Chiodo (rchiodo)
left a comment
Collaborator
There was a problem hiding this comment.
Approved via Review Center.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
str,bytes, or f-string literal (SyntaxError: cannot mix t-string literals with string or bytes literals).t"x" "y"and"" t"x", and inferredTemplate. Adjacent t-string literals (t"a" t"b") remain valid.Unknown.Reproduction (Python 3.14)
CPython:
Root cause
getTypeOfStringListtreated any string list containing a t-string asTemplate, including mixed implicit concatenations. That matched an earlier draft of PEP 750; the final spec and CPython 3.14 disallowTemplate/str(andTemplate/bytes) implicit concatenation.Test plan
tstring2.py: valid t-string implicit concat; mix withstr, f-string, andbytes; explicitTemplate + TemplatevsTemplate + strnpx jest typeEvaluator4.test.ts -t TString --forceExit(pass)npx jest typeEvaluator4.test.ts --forceExit(155 passed)npx jest localizer.test.ts --forceExit(pass)npx jest typeEvaluator8.test.ts -t Strings2 --forceExitfrompackages/pyright-internal(pass)ESLINT_USE_FLAT_CONFIG=false npx eslinton changed TS files (pass)npx prettier -con changed TS/JSON files (pass)npx lerna exec --stream --no-bail --ignore=pyright -- "tsc --noEmit"(pass)git diff --check(pass)Full
packages/pyright-internalnpm testwas not run (includes webpack test server + entire Jest suite). Analyzer coverage for this change is the TString / string-concatenation sample tests.