Skip to content

Commit ab15a36

Browse files
committed
Merge remote-tracking branch 'upstream/main' into release-toml
# Conflicts: # peps/pep-0719.rst
2 parents b680726 + 675d085 commit ab15a36

16 files changed

+1523
-743
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,8 @@ peps/pep-0792.rst @dstufft
674674
peps/pep-0793.rst @encukou
675675
peps/pep-0794.rst @brettcannon
676676
peps/pep-0798.rst @JelleZijlstra
677-
# ...
677+
peps/pep-0799.rst @pablogsal
678+
peps/pep-0800.rst @JelleZijlstra
678679
peps/pep-0801.rst @warsaw
679680
# ...
680681
peps/pep-2026.rst @hugovk

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
- "3.11"
3636
- "3.12"
3737
- "3.13"
38+
- "3.14"
3839
os:
3940
- "windows-latest"
4041
- "macos-latest"

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ venv:
6464
echo "venv already exists."; \
6565
echo "To recreate it, remove it first with \`make clean-venv'."; \
6666
else \
67+
set -e; \
6768
echo "Creating venv in $(VENVDIR)"; \
6869
if $(UV) --version >/dev/null 2>&1; then \
6970
$(UV) venv --python=$(PYTHON) $(VENVDIR); \

peps/pep-0011.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Tier 2
102102
Target Triple Notes Contacts
103103
============================= ========================== ========
104104
aarch64-unknown-linux-gnu glibc, clang Victor Stinner, Gregory P. Smith
105-
wasm32-unknown-wasip1 WASI SDK, Wasmtime Brett Cannon, Eric Snow
105+
wasm32-unknown-wasip1 WASI SDK, Wasmtime Brett Cannon, Michael Droettboom
106106
x86_64-unknown-linux-gnu glibc, clang Victor Stinner, Gregory P. Smith
107107
============================= ========================== ========
108108

peps/pep-0694.rst

Lines changed: 607 additions & 589 deletions
Large diffs are not rendered by default.

peps/pep-0745.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ Actual:
5050
- 3.14.0 beta 2: Monday, 2025-05-26
5151
- 3.14.0 beta 3: Tuesday, 2025-06-17
5252
- 3.14.0 beta 4: Tuesday, 2025-07-08
53+
- 3.14.0 candidate 1: Tuesday, 2025-07-22
5354

5455
Expected:
5556

56-
- 3.14.0 candidate 1: Tuesday, 2025-07-22
5757
- 3.14.0 candidate 2: Tuesday, 2025-08-26
5858
- 3.14.0 final: Tuesday, 2025-10-07
5959

peps/pep-0747.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ expression, and it represents the type described by that type expression.
183183

184184
``TypeForm`` is a special form that, when used in a type expression, describes
185185
a set of type form objects. It accepts a single type argument, which must be a
186-
valid type expression. ``TypeForm[T]`` describes the set of all type form
186+
:ref:`valid type expression <valid-type-expressions>`. ``TypeForm[T]`` describes the set of all type form
187187
objects that represent the type ``T`` or types that are
188188
:term:`assignable to <typing:assignable>` ``T``. For example,
189189
``TypeForm[str | None]`` describes the set of all type form objects
@@ -218,9 +218,7 @@ equivalent to ``TypeForm[Any]``.
218218
Implicit ``TypeForm`` Evaluation
219219
--------------------------------
220220

221-
When a static type checker encounters an expression that follows all of the
222-
syntactic, semantic and contextual rules for a type expression as detailed
223-
in the typing spec, the evaluated type of this expression should be assignable
221+
When a static type checker encounters a valid type expression, the evaluated type of this expression should be assignable
224222
to ``TypeForm[T]`` if the type it describes is assignable to ``T``.
225223

226224
For example, if a static type checker encounters the expression ``str | None``,
@@ -248,6 +246,11 @@ be assignable to ``TypeForm``::
248246

249247
v5: TypeForm[set[str]] = "set[str]" # OK
250248

249+
.. _valid-type-expressions:
250+
251+
Valid Type Expressions
252+
----------------------
253+
251254
The typing spec defines syntactic rules for type expressions in the form of a
252255
:ref:`formal grammar <typing:expression-grammar>`. Semantic rules are specified
253256
as comments along with the grammar definition. Contextual requirements are detailed
@@ -256,8 +259,11 @@ type expressions. For example, the special form ``Self`` can be used in a
256259
type expression only within a class, and a type variable can be used within
257260
a type expression only when it is associated with a valid scope.
258261

259-
Expressions that violate one or more of the syntactic, semantic, or contextual
260-
rules for type expressions should not evaluate to a ``TypeForm`` type.::
262+
A valid type expression is an expression that follows all of the syntactic,
263+
semantic, and contextual rules for a type expression.
264+
265+
Expressions that are not valid type expressions should not evaluate to a
266+
``TypeForm`` type::
261267

262268
bad1: TypeForm = tuple() # Error: Call expression not allowed in type expression
263269
bad2: TypeForm = (1, 2) # Error: Tuple expression not allowed in type expression

peps/pep-0750.rst

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Like ``Template``, it is a new class found in the :mod:`!string.templatelib` mod
209209
def __new__(
210210
cls,
211211
value: object,
212-
expression: str,
212+
expression: str = "",
213213
conversion: Literal["a", "r", "s"] | None = None,
214214
format_spec: str = "",
215215
):
@@ -226,14 +226,20 @@ The ``value`` attribute is the evaluated result of the interpolation:
226226
template = t"Hello {name}"
227227
assert template.interpolations[0].value == "World"
228228
229-
The ``expression`` attribute is the *original text* of the interpolation:
229+
When interpolations are created from a template string literal, the
230+
``expression`` attribute contains the *original text* of the interpolation:
230231

231232
.. code-block:: python
232233
233234
name = "World"
234235
template = t"Hello {name}"
235236
assert template.interpolations[0].expression == "name"
236237
238+
When developers explicitly construct an ``Interpolation``, they may optionally
239+
provide a value for the ``expression`` attribute. Even though it is stored as
240+
a string, this *should* be a valid Python expression. If no value is provided,
241+
the ``expression`` attribute defaults to the empty string (``""``).
242+
237243
We expect that the ``expression`` attribute will not be used in most template
238244
processing code. It is provided for completeness and for use in debugging and
239245
introspection. See both the `Common Patterns Seen in Processing Templates`_
@@ -462,7 +468,9 @@ The debug specifier, ``=``, is supported in template strings and behaves similar
462468
to how it behaves in f-strings, though due to limitations of the implementation
463469
there is a slight difference.
464470

465-
In particular, ``t'{value=}'`` is treated as ``t'value={value!r}'``:
471+
In particular, ``t'{value=}'`` is treated as ``t'value={value!r}'``. The first
472+
static string is rewritten from ``""`` to ``"value="`` and the ``conversion``
473+
defaults to ``r``:
466474

467475
.. code-block:: python
468476
@@ -472,8 +480,11 @@ In particular, ``t'{value=}'`` is treated as ``t'value={value!r}'``:
472480
assert template.interpolations[0].value == "World"
473481
assert template.interpolations[0].conversion == "r"
474482
475-
If a separate format string is also provided, ``t'{value=:fmt}`` is treated
476-
instead as ``t'value={value!s:fmt}'``.
483+
If a conversion is explicitly provided, it is kept: ``t'{value=!s}'``
484+
is treated as ``t'value={value!s}'``.
485+
486+
If a format string is provided without a conversion, the ``conversion``
487+
is set to ``None``: ``t'{value=:fmt}'`` is treated as ``t'value={value:fmt}'``.
477488

478489
Whitespace is preserved in the debug specifier, so ``t'{value = }'`` is
479490
treated as ``t'value = {value!r}'``.
@@ -549,7 +560,7 @@ Examples
549560
========
550561

551562
All examples in this section of the PEP have fully tested reference implementations
552-
available in the public `pep750-examples <https://github.com/davepeck/pep750-examples>`_
563+
available in the public `pep750-examples <https://github.com/t-strings/pep750-examples>`_
553564
git repository.
554565

555566

@@ -602,8 +613,8 @@ specifiers like ``:.2f``. The full code is fairly simple:
602613

603614
See `fstring.py`__ and `test_fstring.py`__.
604615

605-
__ https://github.com/davepeck/pep750-examples/blob/main/pep/fstring.py
606-
__ https://github.com/davepeck/pep750-examples/blob/main/pep/test_fstring.py
616+
__ https://github.com/t-strings/pep750-examples/blob/main/pep/fstring.py
617+
__ https://github.com/t-strings/pep750-examples/blob/main/pep/test_fstring.py
607618

608619

609620
Example: Structured Logging
@@ -775,8 +786,8 @@ logging:
775786

776787
See `logging.py`__ and `test_logging.py`__.
777788

778-
__ https://github.com/davepeck/pep750-examples/blob/main/pep/logging.py
779-
__ https://github.com/davepeck/pep750-examples/blob/main/pep/test_logging.py
789+
__ https://github.com/t-strings/pep750-examples/blob/main/pep/logging.py
790+
__ https://github.com/t-strings/pep750-examples/blob/main/pep/test_logging.py
780791

781792

782793
Example: HTML Templating
@@ -785,7 +796,7 @@ Example: HTML Templating
785796
This PEP contains several short HTML templating examples. It turns out that the
786797
"hypothetical" ``html()`` function mentioned in the `Motivation`_ section
787798
(and a few other places in this PEP) exists and is available in the
788-
`pep750-examples repository <https://github.com/davepeck/pep750-examples/>`_.
799+
`pep750-examples repository <https://github.com/t-strings/pep750-examples/>`_.
789800
If you're thinking about parsing a complex grammar with template strings, we
790801
hope you'll find it useful.
791802

@@ -1081,8 +1092,8 @@ and is able to ``await`` an interpolation's value.
10811092

10821093
See `afstring.py`__ and `test_afstring.py`__.
10831094

1084-
__ https://github.com/davepeck/pep750-examples/blob/main/pep/afstring.py
1085-
__ https://github.com/davepeck/pep750-examples/blob/main/pep/test_afstring.py
1095+
__ https://github.com/t-strings/pep750-examples/blob/main/pep/afstring.py
1096+
__ https://github.com/t-strings/pep750-examples/blob/main/pep/test_afstring.py
10861097

10871098

10881099
Approaches to Template Reuse
@@ -1157,16 +1168,16 @@ which supports the full grammar of format strings.
11571168

11581169
See `format.py`__ and `test_format.py`__.
11591170

1160-
__ https://github.com/davepeck/pep750-examples/blob/main/pep/format.py
1161-
__ https://github.com/davepeck/pep750-examples/blob/main/pep/test_format.py
1171+
__ https://github.com/t-strings/pep750-examples/blob/main/pep/format.py
1172+
__ https://github.com/t-strings/pep750-examples/blob/main/pep/test_format.py
11621173

11631174

11641175
Reference Implementation
11651176
========================
11661177

11671178
A CPython implementation of PEP 750 is `available <https://github.com/lysnikolaou/cpython/tree/tstrings>`_.
11681179

1169-
There is also a public repository of `examples and tests <https://github.com/davepeck/pep750-examples>`_
1180+
There is also a public repository of `examples and tests <https://github.com/t-strings/pep750-examples>`_
11701181
built around the reference implementation. If you're interested in playing with
11711182
template strings, this repository is a great place to start.
11721183

0 commit comments

Comments
 (0)