Skip to content

Commit fbafeff

Browse files
committed
Comment out unsupported syntax
1 parent 201630a commit fbafeff

File tree

5 files changed

+27
-35
lines changed

5 files changed

+27
-35
lines changed

python-t-strings/asynchronous.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# noqa
2-
31
import asyncio
42

53

@@ -9,7 +7,8 @@ async def main():
97

108

119
async def greeting_template():
12-
return t"Hello, {await get_name()}!"
10+
"""Uncomment in Python 3.14+"""
11+
# return t"Hello, {await get_name()}!"
1312

1413

1514
async def get_name():

python-t-strings/escape_html.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# noqa
2-
31
import html
42
from string.templatelib import Template
53

@@ -16,8 +14,9 @@ def generate_safe_html(template):
1614
return "".join(parts)
1715

1816

19-
username = "<script>alert('Hacked!')</script>"
20-
template = t"<p>Hello, {username}!</p>"
21-
22-
safe_html = generate_safe_html(template)
23-
print(safe_html)
17+
# Uncomment in Python 3.14+
18+
# username = "<script>alert('Hacked!')</script>"
19+
# template = t"<p>Hello, {username}!</p>"
20+
#
21+
# safe_html = generate_safe_html(template)
22+
# print(safe_html)

python-t-strings/logging_message.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# noqa
2-
31
import json
42
import logging
53
from string.templatelib import Template
@@ -35,6 +33,7 @@ def __str__(self):
3533
return f"{self.message} >>> {json.dumps(self.values_dict)}"
3634

3735

38-
action, amount, item = "refund", 7, "keyboard"
39-
msg_template = TemplateMessage(t"Process {action}: {amount:.2f} {item}")
40-
logging.info(msg_template)
36+
# Uncomment in Python 3.14+
37+
# action, amount, item = "refund", 7, "keyboard"
38+
# msg_template = TemplateMessage(t"Process {action}: {amount:.2f} {item}")
39+
# logging.info(msg_template)

python-t-strings/sql.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# noqa
2-
31
from string.templatelib import Template
42

53

@@ -20,9 +18,10 @@ def sanitized_sql(template):
2018
return query, tuple(params)
2119

2220

23-
username = "'; DROP TABLE students;--"
24-
template = t"SELECT * FROM students WHERE name = {username}"
25-
query, params = sanitized_sql(template)
26-
27-
print("Sanitized SQL Query:", query)
28-
print("Parameters:", params)
21+
# Uncomment in Python 3.14+
22+
# username = "'; DROP TABLE students;--"
23+
# template = t"SELECT * FROM students WHERE name = {username}"
24+
# query, params = sanitized_sql(template)
25+
#
26+
# print("Sanitized SQL Query:", query)
27+
# print("Parameters:", params)

python-t-strings/to_string.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# noqa
2-
31
from string.templatelib import Template
42

53

@@ -8,9 +6,7 @@ def to_string(template):
86
raise TypeError("t-string expected")
97

108
def convert(value, conversion):
11-
func = {
12-
"a": ascii, "r": repr, "s": str
13-
}.get(conversion, lambda x: x)
9+
func = {"a": ascii, "r": repr, "s": str}.get(conversion, lambda x: x)
1410
return func(value)
1511

1612
parts = []
@@ -19,15 +15,15 @@ def convert(value, conversion):
1915
parts.append(item)
2016
else:
2117
value = format(
22-
convert(item.value, item.conversion),
23-
item.format_spec
18+
convert(item.value, item.conversion), item.format_spec
2419
)
2520
parts.append(value)
2621
return "".join(parts)
2722

2823

29-
price = 234.8765
30-
print(to_string(t"The price is ${price:.2f}"))
31-
32-
header = "Report"
33-
print(to_string(t"{header:=^20}"))
24+
# Uncomment in Python 3.14+
25+
# price = 234.8765
26+
# print(to_string(t"The price is ${price:.2f}"))
27+
#
28+
# header = "Report"
29+
# print(to_string(t"{header:=^20}"))

0 commit comments

Comments
 (0)