checks.license.LicenseCheck
checks.license.LicenseCheck()Check that the package has a license file.
Looks for common license file names (LICENSE, COPYING, etc.) and attempts to identify the license type (MIT, Apache, GPL, etc.).
Attributes
name :-
The check identifier (“license”).
description :-
Human-readable description of this check.
rules :-
The codes of the findings, each with what the rule means.
hints :-
The same codes, each with what to do about the finding.
OSI_APPROVED_SPDX : set[str]-
License identifiers that count as approved by the Open Source Initiative, compared without regard to letter case.
LICENSE_STEMS :-
File name stems searched for in the project root, in any letter case and with any suffix. Override to change the search.
LICENSE_DIRS :-
Directories whose files count as license texts.
LICENSE_FILENAMES :-
No longer used. Kept for code that still reads it.
KNOWN_LICENSES :-
Dictionary mapping license identifiers to text markers used for identification.
Examples
Run the license check:
>>> from pathlib import Path
>>> check = LicenseCheck()
>>> result = check.run(Path("."), {"enabled": True})
>>> result.name
'license'The check identifies common licenses:
>>> # For a package with MIT license
>>> # result.status == CheckStatus.OK
>>> # "License type: MIT" in result.detailsMethods
| Name | Description |
|---|---|
| run | Check for license file presence and validity. |
run
checks.license.LicenseCheck.run(package_path, config)Check for license file presence and validity.
Searches for a license file using common naming conventions, verifies it’s not empty, and reports the license type.
Parameters
Returns
: CheckResult-
A CheckResult with:
: CheckResult-
- OK status if a valid license file is found
: CheckResult-
- NOTE status if the declared license is an SPDX expression that names no license approved by the Open Source Initiative
: CheckResult-
- WARNING status if no license file is found, or the file is empty or cannot be read