From 0681ccee6ab6342e3afd4f99d01db98b9764abc9 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 5 Sep 2024 16:50:26 +0100 Subject: [PATCH] Make error on invalid dynamic metadata more informative --- src/packaging/metadata.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/packaging/metadata.py b/src/packaging/metadata.py index 873c9011..64f2cbe8 100644 --- a/src/packaging/metadata.py +++ b/src/packaging/metadata.py @@ -26,7 +26,7 @@ ExceptionGroup = ExceptionGroup else: # pragma: no cover - class ExceptionGroup(Exception): + class ExceptionGroup(Exception): # type: ignore[no-redef] """A minimal implementation of :external:exc:`ExceptionGroup` from Python 3.11. If :external:exc:`ExceptionGroup` is already defined by Python itself, @@ -589,10 +589,12 @@ def _process_dynamic(self, value: list[str]) -> list[str]: for dynamic_field in map(str.lower, value): if dynamic_field in {"name", "version", "metadata-version"}: raise self._invalid_metadata( - f"{value!r} is not allowed as a dynamic field" + f"{dynamic_field!r} is not allowed as a dynamic field" ) elif dynamic_field not in _EMAIL_TO_RAW_MAPPING: - raise self._invalid_metadata(f"{value!r} is not a valid dynamic field") + raise self._invalid_metadata( + f"{dynamic_field!r} is not a valid dynamic field" + ) return list(map(str.lower, value)) def _process_provides_extra(