fix: handle the license with exception case, e.g., llvmlite#142
Open
joanise wants to merge 1 commit intoFHPythonUtils:masterfrom
Open
fix: handle the license with exception case, e.g., llvmlite#142joanise wants to merge 1 commit intoFHPythonUtils:masterfrom
joanise wants to merge 1 commit intoFHPythonUtils:masterfrom
Conversation
nylocx
reviewed
Feb 4, 2026
|
|
||
| tokens = sorted(parsed.literals) | ||
| pkg_info.license = ucstr(JOINS.join(x.key for x in tokens)) | ||
| pkg_info.license = ucstr(JOINS.join(getattr(x, "key", str(x)) for x in tokens)) |
There was a problem hiding this comment.
Suggested change
| pkg_info.license = ucstr(JOINS.join(getattr(x, "key", str(x)) for x in tokens)) | |
| final_keys = [] | |
| for token in parsed.literals: | |
| final_keys.extend(sub_symbol.key for sub_symbol in token.decompose()) | |
| pkg_info.license = ucstr(JOINS.join(finals_keys)) |
Maybe use the decompose function to get the symbols and not fallback to a simple string representation?
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.
Purpose of This Pull Request
Please check the relevant option by placing an "X" inside the brackets:
Overview of Changes
As described in #137, licensecheck currently hits an unhandled exception when faced with a license with exception, such as is found in
llvmlite.The underlying issue is that not all tokens handled on line 121 of
packageinfo.pyhave akeyattribute.My solution is to guard against this problem with
getattr(x, "key", str(x))which fixes the problem.Related Issue
If this pull request addresses a specific issue, please mention it using the
format "Fixes #IssueNumber"
Fixes #137
Reviewer Focus
It's a pretty simple patch, so nothing specific.
Additional Notes
I wanted to provide unit testing with my PR, but I did not manage to get the existing suite to run correctly on either my Windows or Linux machine. I've added a minimal data file for testing, however:
raises an exception on the current master branch but outputs
llvmlite │ APACHE-2.0 WITH LLVM-EXCEPTION;; BSD-2-CLAUSEas expected with this PR.