diff --git a/.config/dictionary.txt b/.config/dictionary.txt index fb30b67ac94..820b8f9fdb1 100644 --- a/.config/dictionary.txt +++ b/.config/dictionary.txt @@ -189,6 +189,7 @@ levelname libbzip libera libyaml +licensedb lineinfile linenums linkcheck @@ -313,6 +314,7 @@ ruleset runas sarif scalarint +scancode schemafile sdist sdists diff --git a/.config/requirements-test.txt b/.config/requirements-test.txt index 04f169cde36..fb3cd8036d7 100644 --- a/.config/requirements-test.txt +++ b/.config/requirements-test.txt @@ -2,6 +2,7 @@ black # IDE support coverage-enable-subprocess # see https://github.com/nedbat/coveragepy/issues/1341#issuecomment-1228942657 coverage[toml] >= 6.4.4 jmespath +license-expression >= 30.1.1 # Apache 2.0 mypy # IDE support netaddr # needed by ipwrap filter psutil # soft-dep of pytest-xdist @@ -12,6 +13,5 @@ pytest-plus >= 0.2 # for PYTEST_REQPASS pytest-xdist >= 2.1.0 ruamel.yaml>=0.17.31,<0.18 # only the latest is expected to pass our tests ruamel-yaml-clib # needed for mypy -spdx-tools >= 0.7.1,<0.8.0 # Apache types-jsonschema # IDE support types-pyyaml # IDE support diff --git a/.config/requirements.txt b/.config/requirements.txt index 3a3b7b830d2..89e1e0e9a42 100644 --- a/.config/requirements.txt +++ b/.config/requirements.txt @@ -9,8 +9,10 @@ ansible-core==2.15.4 astroid==2.15.8 attrs==23.1.0 babel==2.12.1 +beartype==0.16.2 beautifulsoup4==4.12.2 black==23.9.1 +boolean-py==4.0 bracex==2.4 cairocffi==1.6.1 cairosvg==2.7.1 @@ -44,6 +46,7 @@ jsmin==3.0.1 jsonschema==4.19.1 jsonschema-specifications==2023.7.1 lazy-object-proxy==1.9.0 +license-expression==30.1.1 markdown==3.4.4 markdown-exec==1.6.0 markdown-include==0.8.1 @@ -95,9 +98,9 @@ requests==2.31.0 rich==13.5.3 rpds-py==0.10.3 ruamel-yaml==0.17.33 +semantic-version==2.10.0 six==1.16.0 soupsieve==2.5 -spdx-tools==0.7.1 subprocess-tee==0.4.1 text-unidecode==1.3 tinycss2==1.2.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f132c3166e..ed19257ae48 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -151,12 +151,12 @@ repos: - cryptography>=39.0.1 - filelock>=3.12.2 - jinja2 + - license-expression >= 30.1.1 - pytest-mock - pytest>=7.2.2 - rich>=13.2.0 - - ruamel-yaml>=0.17.31 - ruamel-yaml-clib>=0.2.7 - - spdx-tools>=0.7.1,<0.8.0 + - ruamel-yaml>=0.17.31 - subprocess-tee - types-PyYAML - types-jsonschema>=4.4.2 @@ -181,13 +181,13 @@ repos: - docutils - filelock>=3.12.2 - jsonschema>=4.9.0 + - license-expression >= 30.1.1 - pytest-mock - pytest>=7.2.2 - pyyaml - rich>=13.2.0 - - ruamel-yaml>=0.17.31 - ruamel-yaml-clib>=0.2.7 - - spdx-tools>=0.7.1,<0.8.0 + - ruamel-yaml>=0.17.31 - typing_extensions - wcmatch - yamllint diff --git a/pyproject.toml b/pyproject.toml index 04e04b2aa76..f32d1d9bf39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,10 +113,10 @@ no_incremental = true [[tool.mypy.overrides]] module = [ "ansible.*", - "yamllint.*", "ansiblelint._version", # generated + "license_expression", "ruamel.yaml", - "spdx.*", + "yamllint.*", ] ignore_missing_imports = true ignore_errors = true diff --git a/src/ansiblelint/schemas/__store__.json b/src/ansiblelint/schemas/__store__.json index 7d7a01dd0ad..d2d0c845857 100644 --- a/src/ansiblelint/schemas/__store__.json +++ b/src/ansiblelint/schemas/__store__.json @@ -24,7 +24,7 @@ "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/inventory.json" }, "meta": { - "etag": "d1f66f20b45ecb814d9be900f01451d8035059b312de4a19edc64e29811a7f39", + "etag": "80d83d5c61044aa67496ea22c74aef08b0216c20e318400d3c939927a2761d51", "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/meta.json" }, "meta-runtime": { diff --git a/src/ansiblelint/schemas/galaxy.json b/src/ansiblelint/schemas/galaxy.json index 03b74cc63c0..8af66d4ed21 100644 --- a/src/ansiblelint/schemas/galaxy.json +++ b/src/ansiblelint/schemas/galaxy.json @@ -13,6 +13,7 @@ "description": "An enumeration.", "enum": [ "0BSD", + "389-exception", "AAL", "ADSL", "AFL-1.1", @@ -50,6 +51,9 @@ "Artistic-1.0-Perl", "Artistic-1.0-cl8", "Artistic-2.0", + "Autoconf-exception-2.0", + "Autoconf-exception-3.0", + "Autoconf-exception-generic", "BSD-1-Clause", "BSD-2-Clause", "BSD-2-Clause-Patent", @@ -79,11 +83,13 @@ "Bahyph", "Barr", "Beerware", + "Bison-exception-2.2", "BitTorrent-1.0", "BitTorrent-1.1", "Bitstream-Charter", "Bitstream-Vera", "BlueOak-1.0.0", + "Bootloader-exception", "Borceux", "Brian-Gladman-3-Clause", "C-UDA-1.0", @@ -159,6 +165,7 @@ "CERN-OHL-S-2.0", "CERN-OHL-W-2.0", "CFITSIO", + "CLISP-exception-2.0", "CMU-Mach", "CNRI-Jython", "CNRI-Python", @@ -170,6 +177,7 @@ "CUA-OPL-1.0", "Caldera", "ClArtistic", + "Classpath-exception-2.0", "Clips", "Community-Spec-1.0", "Condor-1.1", @@ -182,6 +190,7 @@ "DOC", "DRL-1.0", "DSDP", + "DigiRule-FOSS-exception", "Dotseqn", "ECL-1.0", "ECL-2.0", @@ -199,15 +208,20 @@ "ErlPL-1.1", "Eurosym", "FDK-AAC", + "FLTK-exception", "FSFAP", "FSFUL", "FSFULLR", "FSFULLRWD", "FTL", "Fair", + "Fawkes-Runtime-exception", + "Font-exception-2.0", "Frameworx-1.0", "FreeBSD-DOC", "FreeImage", + "GCC-exception-2.0", + "GCC-exception-3.1", "GD", "GFDL-1.1-invariants-only", "GFDL-1.1-invariants-or-later", @@ -229,12 +243,18 @@ "GFDL-1.3-or-later", "GL2PS", "GLWTPL", + "GNAT-exception", "GPL-1.0-only", "GPL-1.0-or-later", "GPL-2.0-only", "GPL-2.0-or-later", + "GPL-3.0-linking-exception", + "GPL-3.0-linking-source-exception", "GPL-3.0-only", "GPL-3.0-or-later", + "GPL-CC-1.0", + "GStreamer-exception-2005", + "GStreamer-exception-2008", "Giftware", "Glide", "Glulxe", @@ -268,6 +288,7 @@ "Jam", "JasPer-2.0", "Kazlib", + "KiCad-libraries-exception", "Knuth-CTAN", "LAL-1.2", "LAL-1.3", @@ -275,9 +296,11 @@ "LGPL-2.0-or-later", "LGPL-2.1-only", "LGPL-2.1-or-later", + "LGPL-3.0-linking-exception", "LGPL-3.0-only", "LGPL-3.0-or-later", "LGPLLR", + "LLVM-exception", "LOOP", "LPL-1.0", "LPL-1.02", @@ -288,14 +311,17 @@ "LPPL-1.3c", "LZMA-SDK-9.11-to-9.20", "LZMA-SDK-9.22", + "LZMA-exception", "Latex2e", "Leptonica", "LiLiQ-P-1.1", "LiLiQ-R-1.1", "LiLiQ-Rplus-1.1", "Libpng", + "Libtool-exception", "Linux-OpenIB", "Linux-man-pages-copyleft", + "Linux-syscall-note", "MIT", "MIT-0", "MIT-CMU", @@ -350,7 +376,9 @@ "Noweb", "O-UDA-1.0", "OCCT-PL", + "OCCT-exception-1.0", "OCLC-2.0", + "OCaml-LGPL-linking-exception", "ODC-By-1.0", "ODbL-1.0", "OFFIS", @@ -392,11 +420,13 @@ "OSL-2.0", "OSL-2.1", "OSL-3.0", + "OpenJDK-assembly-exception-1.0", "OpenPBS-2.3", "OpenSSL", "PDDL-1.0", "PHP-3.0", "PHP-3.01", + "PS-or-PDF-font-exception-20170817", "PSF-2.0", "Parity-6.0.0", "Parity-7.0.0", @@ -408,7 +438,11 @@ "Python-2.0.1", "QPL-1.0", "QPL-1.0-INRIA-2004", + "QPL-1.0-INRIA-2004-exception", "Qhull", + "Qt-GPL-exception-1.0", + "Qt-LGPL-exception-1.1", + "Qwt-exception-1.0", "RHeCos-1.1", "RPL-1.1", "RPL-1.5", @@ -424,6 +458,8 @@ "SGI-B-2.0", "SHL-0.5", "SHL-0.51", + "SHL-2.0", + "SHL-2.1", "SISSL", "SISSL-1.2", "SMLNJ", @@ -433,6 +469,7 @@ "SSH-OpenSSH", "SSH-short", "SSPL-1.0", + "SWI-exception", "SWL", "Saxpath", "SchemeReport", @@ -445,6 +482,7 @@ "Spencer-99", "SugarCRM-1.1.3", "SunPro", + "Swift-exception", "Symlinks", "TAPR-OHL-1.0", "TCL", @@ -463,6 +501,7 @@ "Unicode-DFS-2015", "Unicode-DFS-2016", "Unicode-TOU", + "Universal-FOSS-exception-1.0", "Unlicense", "VOSTROM", "VSL-1.0", @@ -473,6 +512,7 @@ "WTFPL", "Watcom-1.0", "Wsuipa", + "WxWindows-exception-3.1", "X11", "X11-distribute-modifications-variant", "XFree86-1.1", @@ -497,22 +537,30 @@ "curl", "diffmark", "dvipdfm", + "eCos-exception-2.0", "eGenix", "etalab-2.0", + "freertos-exception-2.0", "gSOAP-1.3b", + "gnu-javamail-exception", "gnuplot", + "i2p-gpl-java-exception", "iMatix", "libpng-2.0", "libselinux-1.0", "libtiff", "libutil-David-Nugent", + "mif-exception", "mpi-permissive", "mpich2", "mplus", + "openvpn-openssl-exception", "psfrag", "psutils", "snprintf", + "u-boot-exception-2.0", "w3m", + "x11vnc-openssl-exception", "xinetd", "xlock", "xpp", diff --git a/test/test_schemas.py b/test/test_schemas.py index 639224180c9..0356d1a767d 100644 --- a/test/test_schemas.py +++ b/test/test_schemas.py @@ -9,8 +9,8 @@ from typing import Any from unittest.mock import DEFAULT, MagicMock, patch +import license_expression import pytest -import spdx.config from ansiblelint.file_utils import Lintable from ansiblelint.schemas import __file__ as schema_module @@ -18,7 +18,9 @@ from ansiblelint.schemas.main import validate_file_schema schema_path = Path(schema_module).parent -spdx_config_path = Path(spdx.config.__file__).parent +spdx_config_path = ( + Path(license_expression.__file__).parent / "data" / "scancode-licensedb-index.json" +) def test_refresh_schemas() -> None: @@ -86,15 +88,18 @@ def test_validate_file_schema() -> None: def test_spdx() -> None: """Test that SPDX license identifiers are in sync.""" - _licenses = spdx_config_path / "licenses.json" - license_ids = set() - with _licenses.open(encoding="utf-8") as license_fh: + with spdx_config_path.open(encoding="utf-8") as license_fh: licenses = json.load(license_fh) - for lic in licenses["licenses"]: - if lic.get("isDeprecatedLicenseId"): + for lic in licenses: + # for lic in lic_dic: + # breakpoint() + if lic.get("is_deprecated"): + continue + lic_id = lic["spdx_license_key"] + if lic_id.startswith("LicenseRef"): continue - license_ids.add(lic["licenseId"]) + license_ids.add(lic_id) galaxy_json = schema_path / "galaxy.json" with galaxy_json.open(encoding="utf-8") as f: