Skip to content

Commit 783de47

Browse files
committed
Prefer license expression
1 parent 3f95b76 commit 783de47

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/pipdeptree/_models/package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def licenses(self) -> str:
3939
except PackageNotFoundError:
4040
return self.UNKNOWN_LICENSE_STR
4141

42-
license_strs: list[str] = []
4342
if license_str := dist_metadata.get("License-Expression"):
44-
license_strs.append(license_str)
43+
return f"({license_str})"
4544

45+
license_strs: list[str] = []
4646
classifiers = dist_metadata.get_all("Classifier", [])
4747
for classifier in classifiers:
4848
line = str(classifier)

tests/_models/test_package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ def test_dist_package_as_dict() -> None:
148148
Mock(
149149
get=lambda *args, **kwargs: "MIT", # noqa: ARG005
150150
get_all=lambda *args, **kwargs: [ # noqa: ARG005
151-
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
151+
"License :: OSI Approved :: MIT License",
152152
],
153153
),
154-
"(MIT, GNU General Public License v2 (GPLv2))",
154+
"(MIT)",
155155
id="license-expression-with-license-classifier",
156156
),
157157
],

0 commit comments

Comments
 (0)