Skip to content

Commit

Permalink
Make error on invalid dynamic metadata more informative
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Sep 5, 2024
1 parent 20f51f0 commit c0ee2d6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/packaging/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c0ee2d6

Please sign in to comment.