From e365746fd934237879bf59fcd4f65c22d8149c6a Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Sat, 24 May 2025 22:13:33 +0200 Subject: [PATCH] scripts: west_commands: zspdx: scanner: Fix linter issues Fix issues reported by ruff. Signed-off-by: Pieter De Gendt --- .ruff-excludes.toml | 5 ----- scripts/west_commands/zspdx/scanner.py | 8 +++----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/.ruff-excludes.toml b/.ruff-excludes.toml index 3f5c557c66e..be49afe4ea4 100644 --- a/.ruff-excludes.toml +++ b/.ruff-excludes.toml @@ -1190,11 +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/scanner.py" = [ - "SIM113", # https://docs.astral.sh/ruff/rules/enumerate-for-loop - "UP008", # https://docs.astral.sh/ruff/rules/super-call-with-parameters - "UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes -] "./scripts/west_commands/zspdx/walker.py" = [ "E501", # https://docs.astral.sh/ruff/rules/line-too-long "F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders diff --git a/scripts/west_commands/zspdx/scanner.py b/scripts/west_commands/zspdx/scanner.py index 21975242acd..2a4ac792b9c 100644 --- a/scripts/west_commands/zspdx/scanner.py +++ b/scripts/west_commands/zspdx/scanner.py @@ -16,7 +16,7 @@ from zspdx.util import getHashes # Document scanning should occur. class ScannerConfig: def __init__(self): - super(ScannerConfig, self).__init__() + super().__init__() # when assembling a Package's data, should we auto-conclude the # Package's license, based on the licenses of its Files? @@ -63,11 +63,9 @@ def getExpressionData(filePath, numLines): """ log.dbg(f" - getting licenses for {filePath}") - with open(filePath, "r") as f: + with open(filePath) as f: try: - lineno = 0 - for line in f: - lineno += 1 + for lineno, line in enumerate(f, start=1): if lineno > numLines > 0: break expression = parseLineForExpression(line)