load lint_licenses where it is needed to avoid circular imports

This is the only thing that common.py imports from lint.py.
This commit is contained in:
Hans-Christoph Steiner 2025-03-06 10:10:25 +01:00
parent 16fb0fbe91
commit 53b62415d3
2 changed files with 14 additions and 7 deletions

View file

@ -66,7 +66,6 @@ from urllib.parse import urlparse, urlsplit, urlunparse
from zipfile import ZipFile from zipfile import ZipFile
import fdroidserver.metadata import fdroidserver.metadata
import fdroidserver.lint
from fdroidserver import _ from fdroidserver import _
from fdroidserver.exception import FDroidException, VCSException, NoSubmodulesException, \ from fdroidserver.exception import FDroidException, VCSException, NoSubmodulesException, \
BuildException, VerificationException, MetaDataException BuildException, VerificationException, MetaDataException
@ -187,7 +186,6 @@ default_config = {
'archive_name': 'My First F-Droid Archive Demo', 'archive_name': 'My First F-Droid Archive Demo',
'archive_description': _('These are the apps that have been archived from the main repo.'), # type: ignore 'archive_description': _('These are the apps that have been archived from the main repo.'), # type: ignore
'archive_older': 0, 'archive_older': 0,
'lint_licenses': fdroidserver.lint.APPROVED_LICENSES, # type: ignore
'git_mirror_size_limit': 10000000000, 'git_mirror_size_limit': 10000000000,
'scanner_signature_sources': ['suss'], 'scanner_signature_sources': ['suss'],
} }

View file

@ -578,11 +578,20 @@ def check_format(app):
def check_license_tag(app): def check_license_tag(app):
"""Ensure all license tags contain only valid/approved values.""" """Ensure all license tags contain only valid/approved values.
if config['lint_licenses'] is None:
It is possible to disable license checking by setting a null or empty value,
e.g. `lint_licenses: ` or `lint_licenses: []`
"""
if 'lint_licenses' in config:
lint_licenses = config['lint_licenses']
if lint_licenses is None:
return return
if app.License not in config['lint_licenses']: else:
if config['lint_licenses'] == APPROVED_LICENSES: lint_licenses = APPROVED_LICENSES
if app.License not in lint_licenses:
if lint_licenses == APPROVED_LICENSES:
yield _( yield _(
'Unexpected license tag "{}"! Only use FSF or OSI ' 'Unexpected license tag "{}"! Only use FSF or OSI '
'approved tags from https://spdx.org/license-list' 'approved tags from https://spdx.org/license-list'