Skip to content

feat: Add PEP 750 template string support #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

koxudaxi
Copy link

@koxudaxi koxudaxi commented May 29, 2025

Adds parsing support for PEP 750 Template Strings, a new Python 3.14 feature that introduces t-strings for safer templating.

Overview

Template strings use the t prefix and create Template objects instead of regular strings, enabling secure HTML/SQL templating and DSL support:

# Basic template string
name = "world"
template = t"Hello, {name}!"

# Multi-line with format specifiers
html = t"""
<div class="user">
    <h1>{user.name}</h1>
    <p>Score: {score:04d}</p>
</div>
"""

Changes

  • Added Template flag to scanner for t-prefixed string literals
  • Extended scanner to recognize t/T prefixes (supports tr/rt combinations)
  • Template strings reuse existing f-string interpolation mechanism
  • Added comprehensive test coverage with 8 test cases

Related

Template strings will be available in Python 3.14.0b1+ and officially released in Python 3.14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant