Skip to content

Commit 2829ccc

Browse files
committed
Simplify matches_have_unknown license function
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 8af86ce commit 2829ccc

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/packagedcode/licensing.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -583,17 +583,13 @@ def get_license_expression_from_detection_mappings(
583583
)
584584

585585

586-
def matches_have_unknown(matches, licensing=Licensing()):
586+
def matches_have_unknown(matches):
587587
"""
588-
Return True if any of the LicenseMatch in `matches` has an unknown license.
588+
Return True if any of the LicenseMatch in ``matches`` has an unknown license.
589+
Note that by construction and design, an unknown license must have the word "unknown" in its
590+
license key, so we can shortcut the test with a string check.
589591
"""
590-
for match in matches:
591-
exp = match.rule.license_expression_object
592-
if any(
593-
key in ('unknown', 'unknown-spdx')
594-
for key in licensing.license_keys(exp)
595-
):
596-
return True
592+
return any('unknown' in match.rule.license_expression for match in matches)
597593

598594

599595
def get_license_detections_from_matches(matches):

0 commit comments

Comments
 (0)