From e7fb14bed0c7c49212e4f222d477f1dd54d99eab Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Sun, 13 Sep 2026 13:15:06 -0400 Subject: [PATCH] The SPDX gate fails on a file it cannot read instead of skipping it, and the changelog says licence A silent skip would let an unmarked file through, which is the one thing the test exists to catch. The two new changelog lines now read in the file's own voice, and a docstring in the logging tests is wrapped under the line limit. Co-Authored-By: Claude Fable 5.1 --- CHANGELOG.md | 4 ++-- tests/test_logging.py | 4 ++-- tests/test_spdx.py | 21 +++++---------------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81d43b0..046a3e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,9 +19,9 @@ allowed to change behaviour, not just add to it. ### Added -- **All Python files declare their license with SPDX identifiers** on line 1 (or line 2 after a shebang), enforced by a new `tests/test_spdx.py` gate. A file lifted from the repository carries no license marking otherwise. +- **Every Python file names its licence with an SPDX identifier** on its first line (second, after a shebang), and `tests/test_spdx.py` keeps a new file from landing without one. Apache-2.0 does not require per-file headers, but a file lifted out of the tree carried no marking at all. -- **The XIAO firmware patch and builder carry the MeshCore MIT license** in `scripts/xiao-radio/LICENSE.MeshCore`, and the dual-licensing of the shared font generator (Apache-2.0 and GPL-2.0-only) is documented in the script headers and `docs/hardware.md`. +- **The XIAO firmware patch carries MeshCore's MIT notice beside it** as `scripts/xiao-radio/LICENSE.MeshCore`, and the console-font scripts state that the shared generator block is offered under GPL-2.0-only as well as Apache-2.0, which is what lets the GPL-2.0-only 6×8 script run it. - **The SPI radio bridge runs on `openhop_core`.** The library the uConsole's software node runs on was renamed from `pymc_core` in 2026, and the current `meshcore-uconsole` diff --git a/tests/test_logging.py b/tests/test_logging.py index 0f22a11..c990637 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -103,8 +103,8 @@ def test_a_level_name_becomes_a_level(tmp_path: Path) -> None: def test_a_nonsense_level_still_starts_the_app() -> None: """A typo in a hand-edited preferences file loses log detail, not the app. - Someone editing the preferences file by hand and writing ``WARN`` should get a slightly quieter log, - not a program that refuses to launch. + Someone editing the preferences file by hand and writing ``WARN`` should get a + slightly quieter log, not a program that refuses to launch. """ assert level_from_name("WARN") == logging.WARNING assert level_from_name("") == logging.WARNING diff --git a/tests/test_spdx.py b/tests/test_spdx.py index 6e9f862..c39fd4a 100644 --- a/tests/test_spdx.py +++ b/tests/test_spdx.py @@ -34,22 +34,11 @@ def test_spdx_headers(): missing_spdx = [] for filepath in sorted(python_files): - try: - content = filepath.read_text(encoding="utf-8") - lines = content.split("\n", 2) # Check first 2 lines max - - # Check for SPDX identifier on line 1 or 2 - has_spdx = False - if lines and "SPDX-License-Identifier:" in lines[0]: - has_spdx = True - elif len(lines) > 1 and "SPDX-License-Identifier:" in lines[1]: - has_spdx = True - - if not has_spdx: - missing_spdx.append(str(filepath.relative_to(repo_root))) - except Exception: - # Skip files that can't be read - continue + # A file that cannot be read as UTF-8 is a finding, not something to skip: every + # source file here is UTF-8, and a silent skip would let an unmarked file through. + head = filepath.read_text(encoding="utf-8").split("\n", 2)[:2] + if not any("SPDX-License-Identifier:" in line for line in head): + missing_spdx.append(str(filepath.relative_to(repo_root))) assert not missing_spdx, ( f"Found {len(missing_spdx)} Python file(s) without SPDX-License-Identifier:\n"