scripts: west_commands: zspdx: sbom: Fix linter issues

Fix issues reported by ruff.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2025-05-24 22:10:39 +02:00 committed by Benjamin Cabé
commit 10bd714110
2 changed files with 6 additions and 12 deletions

View file

@ -1190,12 +1190,6 @@
"UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes
"UP032", # https://docs.astral.sh/ruff/rules/f-string
]
"./scripts/west_commands/zspdx/sbom.py" = [
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports
"SIM115", # https://docs.astral.sh/ruff/rules/open-file-with-context-handler
"UP008", # https://docs.astral.sh/ruff/rules/super-call-with-parameters
]
"./scripts/west_commands/zspdx/scanner.py" = [
"SIM113", # https://docs.astral.sh/ruff/rules/enumerate-for-loop
"UP008", # https://docs.astral.sh/ruff/rules/super-call-with-parameters

View file

@ -6,8 +6,8 @@ import os
from west import log
from zspdx.walker import WalkerConfig, Walker
from zspdx.scanner import ScannerConfig, scanDocument
from zspdx.walker import Walker, WalkerConfig
from zspdx.writer import writeSPDX
@ -15,7 +15,7 @@ from zspdx.writer import writeSPDX
# SBOM maker subcomponents.
class SBOMConfig:
def __init__(self):
super(SBOMConfig, self).__init__()
super().__init__()
# prefix for Document namespaces; should not end with "/"
self.namespacePrefix = ""
@ -58,8 +58,8 @@ def setupCmakeQuery(build_dir):
return True
else:
# file doesn't exist, let's create an empty file
cm_fd = open(queryFilePath, "w")
cm_fd.close()
with open(queryFilePath, "w"):
pass
return True
@ -69,8 +69,8 @@ def setupCmakeQuery(build_dir):
def makeSPDX(cfg):
# report any odd configuration settings
if cfg.analyzeIncludes and not cfg.includeSDK:
log.wrn(f"config: requested to analyze includes but not to generate SDK SPDX document;")
log.wrn(f"config: will proceed but will discard detected includes for SDK header files")
log.wrn("config: requested to analyze includes but not to generate SDK SPDX document;")
log.wrn("config: will proceed but will discard detected includes for SDK header files")
# set up walker configuration
walkerCfg = WalkerConfig()