scripts: Fix twisterlib for ruff - SIM114

This fixes ruff linting error SIM114,
where there are multiple arms in an
if-elif-else construct with the same result.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
This commit is contained in:
Lukasz Mrugala 2024-11-27 11:37:10 +00:00 committed by Carles Cufí
commit f80f3771a7
3 changed files with 2 additions and 9 deletions

View file

@ -761,7 +761,6 @@
"./scripts/pylib/twister/twisterlib/cmakecache.py" = [
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
"SIM102", # https://docs.astral.sh/ruff/rules/collapsible-if
"SIM114", # https://docs.astral.sh/ruff/rules/if-with-same-arms
"UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes
"UP032", # https://docs.astral.sh/ruff/rules/f-string
]
@ -793,7 +792,6 @@
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders
"SIM102", # https://docs.astral.sh/ruff/rules/collapsible-if
"SIM105", # https://docs.astral.sh/ruff/rules/suppressible-exception
"SIM114", # https://docs.astral.sh/ruff/rules/if-with-same-arms
"SIM115", # https://docs.astral.sh/ruff/rules/open-file-with-context-handler
"UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation
"UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes

View file

@ -52,9 +52,7 @@ class CMakeCacheEntry:
val = val.upper()
if val in ('ON', 'YES', 'TRUE', 'Y'):
return 1
elif val in ('OFF', 'NO', 'FALSE', 'N', 'IGNORE', 'NOTFOUND', ''):
return 0
elif val.endswith('-NOTFOUND'):
elif val in ('OFF', 'NO', 'FALSE', 'N', 'IGNORE', 'NOTFOUND', '') or val.endswith('-NOTFOUND'):
return 0
else:
try:

View file

@ -554,10 +554,7 @@ class DeviceHandler(Handler):
if runner in ("pyocd", "nrfjprog", "nrfutil"):
command_extra_args.append("--dev-id")
command_extra_args.append(board_id)
elif runner == "openocd" and product == "STM32 STLink":
command_extra_args.append("--cmd-pre-init")
command_extra_args.append("hla_serial %s" % board_id)
elif runner == "openocd" and product == "STLINK-V3":
elif runner == "openocd" and product == "STM32 STLink" or runner == "openocd" and product == "STLINK-V3":
command_extra_args.append("--cmd-pre-init")
command_extra_args.append("hla_serial %s" % board_id)
elif runner == "openocd" and product == "EDBG CMSIS-DAP":