Skip to content

Commit db8bb30

Browse files
Merge pull request #1374 from rd4398/fix-1372
fix(pkgmetadata): raise ValueError when no classifier maps to SPDX
2 parents f3e9d26 + 81056e3 commit db8bb30

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎src/fromager/pkgmetadata/pep639.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def _trove_to_spdx(troves: list[str]) -> LicenseExpression:
8181
if mapped is None:
8282
raise ValueError(f"{trove!r} is ambiguous")
8383
trove_spdx.append(mapped)
84+
if not trove_spdx:
85+
raise ValueError("no classifier maps to a SPDX license expression")
8486
# join with AND
8587
return _parse_spdx(" AND ".join(trove_spdx), simplify=True)
8688

‎tests/test_pkgmetadata.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ def test_license_from_metadata(metadata: Metadata, expected: str) -> None:
108108
(None, None, None),
109109
(None, "invalid", None),
110110
(None, None, ["License :: OSI Approved :: BSD License"]),
111+
# classifiers with no entry that maps to SPDX (see issue #1372)
112+
(None, None, ["Programming Language :: Python :: 3"]),
113+
(None, None, ["License :: OSI Approved"]),
114+
# non-license classifier alongside an ambiguous license classifier
115+
(
116+
None,
117+
None,
118+
[
119+
"Programming Language :: Python :: 3",
120+
"License :: OSI Approved :: BSD License",
121+
],
122+
),
111123
],
112124
)
113125
def test_license_from_metadata_errors(

0 commit comments

Comments
 (0)