Skip to content

Commit c17f3a4

Browse files
committed
chore: use partition in _parse_project_urls
Signed-off-by: Henry Schreiner <[email protected]>
1 parent c87e4df commit c17f3a4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/packaging/metadata.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,14 @@ def _parse_project_urls(data: list[str]) -> dict[str, str]:
209209
# answer with what to do in that case. As such, we'll do the only
210210
# thing we can, which is treat the field as unparsable and add it
211211
# to our list of unparsed fields.
212-
parts = [p.strip() for p in pair.split(",", 1)]
213-
parts.extend([""] * (max(0, 2 - len(parts)))) # Ensure 2 items
214-
212+
#
215213
# TODO: The spec doesn't say anything about if the keys should be
216214
# considered case sensitive or not... logically they should
217215
# be case-preserving and case-insensitive, but doing that
218216
# would open up more cases where we might have duplicate
219217
# entries.
220-
label, url = parts
218+
label, _, url = (s.strip() for s in pair.partition(","))
219+
221220
if label in urls:
222221
# The label already exists in our set of urls, so this field
223222
# is unparsable, and we can just add the whole thing to our

0 commit comments

Comments
 (0)