Add support for t-strings (PEP 750).#20850
Conversation
Co-authored-by: Brian Schubert <[email protected]> Co-authored-by: Claude <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
On Python < 3.14, ast_Interpolation is Any. Avoid typing error by using "type: ignore". This matches what is done for `ast_TypeVarTuple`.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
JukkaL
left a comment
There was a problem hiding this comment.
Thanks for the PR! It's important to have support for all Python features. This looks pretty good overall. There is at least one issues I could find (missing implicit dependency to string.templatelib), but it's easy enough for me to fix myself, so I'll prepare a follow-up PR soon and we can merge this. I'll also add some more test coverage.
|
@nascheme |
|
If what I am saying above is desired but non-trivial, please open a follow-up issue so that we will not forget about it. |
If a file uses t-strings, implicitly depend on `string.templatelib`. Also improve test coverage a bit. Follow-up to #20850.
These are unsupported by mypyc for now. Follow-up to #20850.
This is based on the #19333 by @brianschubert. I (with the help of Claude Code) modified as suggested by the PR comments to add mypy AST nodes. I'm not very familiar with mypy internals but this seems to work. Tests have been added to check that t-strings are handled as expected. I also tested with Python 3.13 to ensure this doesn't break with older versions.
Fixes #19329