From 7b2491eb248a91b392f95fef10a5a0b19910f9c6 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 17 Nov 2025 12:06:04 -0500 Subject: [PATCH] PEP 808: backwards compatibility example update Signed-off-by: Henry Schreiner --- peps/pep-0808.rst | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/peps/pep-0808.rst b/peps/pep-0808.rst index 79cb422f327..fb4e0ed4725 100644 --- a/peps/pep-0808.rst +++ b/peps/pep-0808.rst @@ -273,6 +273,9 @@ metadata. Backwards Compatibility ======================= +Using metadata from SDists or wheels is unaffected. The METADATA version does +not need to be incremented. + This does not affect any existing ``pyproject.toml``'s, since this was strictly not allowed before this PEP. @@ -283,8 +286,27 @@ frontends may need to be updated to benefit from the partially static metadata. Some frontends and other tooling may need updating, such as schema validation, just like other ``pyproject.toml`` PEPs. -Using metadata from SDists or wheels is unaffected. The METADATA version does -not need to be incremented. +Static analysis tools may require updating to handle this change. Tools should +check the dynamic table first, like this: + +.. code-block:: + + match pyproject["project"]: + # New in PEP 808 + case {my.key: value, "dynamic": dyn} if my.key in dyn: + print(f"Partial {my.key}: {value}") + case {"dynamic": dyn} if my.key in dyn: + print(f"Fully dynamic {my.key}") + case {my.key: value}: + print(f"Fully static {my.key}: {value}") + case _: + print(f"No metadata for {my.key}") + +Before this PEP, tools could reverse the order of the dynamic and static +blocks, assuming that an entry in the project table meant it could not be +dynamic. If they do this, they will now incorrectly assume they have all the +metadata for a field, when they in fact only have part of it. + Security Implications =====================