tofusoup
2026-03-22
Ruff linter compliance fixes to SPDX header scripts (E741, C901, SIM103)
2 files · 41+ · 45-
Ruff linter compliance: SPDX header scripts
2 files changed
add_spdx_headers.pyExtracted _check_existing_header() to reduce complexity of add_header() (C901); normalized string quotes to double; modernized Tuple[...] to tuple[...] built-in; reordered imports; reformatted multi-line list concatenationvalidate_spdx_headers.pyNormalized string quotes to double; simplified boolean return (SIM103: return bool(is_nearly_empty(...)) instead of if/else); reordered imports
- Extracted _check_existing_header() from add_header() to bring the function under ruff’s C901 complexity threshold. The extracted helper returns a result tuple to signal early return, or None to continue — preserving the original logic path exactly.
remediate
errata
1 file
add_spdx_headers.py
- Replaced Tuple[bool, str] annotations with the built-in tuple[bool, str] form (PEP 585, Python 3.9+). Normalized all string literals from single to double quotes across both files. Reordered stdlib imports to satisfy ruff import ordering rules.
remediate
errata
2 files
add_spdx_headers.pyvalidate_spdx_headers.py
- Simplified the skip_file() return in validate_spdx_headers.py from an explicit if/else to return bool(is_nearly_empty(file_path)), resolving SIM103.
remediate
errata
1 file
validate_spdx_headers.py