From 10bd714110261102cb1590de99e4dc4758ea9d76 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Sat, 24 May 2025 22:10:39 +0200 Subject: [PATCH] scripts: west_commands: zspdx: sbom: Fix linter issues Fix issues reported by ruff. Signed-off-by: Pieter De Gendt --- .ruff-excludes.toml | 6 ------ scripts/west_commands/zspdx/sbom.py | 12 ++++++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.ruff-excludes.toml b/.ruff-excludes.toml index dcb5781e90b..3f5c557c66e 100644 --- a/.ruff-excludes.toml +++ b/.ruff-excludes.toml @@ -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 diff --git a/scripts/west_commands/zspdx/sbom.py b/scripts/west_commands/zspdx/sbom.py index dceda34fcaf..459210eba83 100644 --- a/scripts/west_commands/zspdx/sbom.py +++ b/scripts/west_commands/zspdx/sbom.py @@ -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()