scripts: west_commands: zspdx: scanner: 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:13:33 +02:00 committed by Benjamin Cabé
commit e365746fd9
2 changed files with 3 additions and 10 deletions

View file

@ -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

View file

@ -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)