Skip to content

Commit 93f3c30

Browse files
authored
PEP 808: backwards compatibility example update (#4710)
1 parent edbdf98 commit 93f3c30

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

peps/pep-0808.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ metadata.
273273
Backwards Compatibility
274274
=======================
275275

276+
Using metadata from SDists or wheels is unaffected. The METADATA version does
277+
not need to be incremented.
278+
276279
This does not affect any existing ``pyproject.toml``'s, since this was strictly
277280
not allowed before this PEP.
278281

@@ -283,8 +286,27 @@ frontends may need to be updated to benefit from the partially static metadata.
283286
Some frontends and other tooling may need updating, such as schema
284287
validation, just like other ``pyproject.toml`` PEPs.
285288

286-
Using metadata from SDists or wheels is unaffected. The METADATA version does
287-
not need to be incremented.
289+
Static analysis tools may require updating to handle this change. Tools should
290+
check the dynamic table first, like this:
291+
292+
.. code-block::
293+
294+
match pyproject["project"]:
295+
# New in PEP 808
296+
case {my.key: value, "dynamic": dyn} if my.key in dyn:
297+
print(f"Partial {my.key}: {value}")
298+
case {"dynamic": dyn} if my.key in dyn:
299+
print(f"Fully dynamic {my.key}")
300+
case {my.key: value}:
301+
print(f"Fully static {my.key}: {value}")
302+
case _:
303+
print(f"No metadata for {my.key}")
304+
305+
Before this PEP, tools could reverse the order of the dynamic and static
306+
blocks, assuming that an entry in the project table meant it could not be
307+
dynamic. If they do this, they will now incorrectly assume they have all the
308+
metadata for a field, when they in fact only have part of it.
309+
288310

289311
Security Implications
290312
=====================

0 commit comments

Comments
 (0)