Reduce dependencies for license scanning API - #5298
Open
shivd1410 wants to merge 1 commit into
Open
Conversation
Signed-off-by: Shivam Pandey <sd.scores4455@gmail.com>
shivd1410
force-pushed
the
fix-5115-license-api-dependencies
branch
from
September 4, 2026 05:04
8a56b44 to
ea97933
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5115
Summary
This PR reduces the dependencies loaded when using
scancode.api.get_licenses().Changes
packagedcode.utilsimport fromget_licenses().combine_expressionsdirectly fromlicense_expressioninstead.typecodeimports into the functions where file-type information is actually needed.get_licenses()does not loadtypecode,extractcode, orpackagedcode.Procedure
I started by tracing the imports pulled in when importing
scancode.api.get_licenses().packagedcode.utilswas pulling in a much larger package-scanning dependency tree, even thoughget_licenses()only neededcombine_expressions.typecodeimport was also pulling inextractcodeand other dependencies through its import chain.typecodewas actually used and moved those imports to those specific functions instead of loading it when the module is imported.Testing
get_licenses()functional check: passed (MITdetected correctly)pytest tests/scancode/test_api.py: 11 passed, 2 failedlicensedcode/cache.pyboolean-expression handling and are unrelated to these changes.git diff --check: passedCI
ClueCode, misc/scancode, and cross-platform test suites.
license_expressionboolean-evaluation failure was also reproducedlocally in the existing API tests and is unrelated to the changes in this PR.
get_licenses()import passes.