scripts: Fix twisterlib for ruff - B009

This fixes ruff linting error B009,
where getattr() was used with a
constant field name.

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
This commit is contained in:
Lukasz Mrugala 2024-11-27 12:45:41 +00:00 committed by Carles Cufí
commit 1eed6dfaa9
2 changed files with 1 additions and 2 deletions

View file

@ -800,7 +800,6 @@
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting "UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
] ]
"./scripts/pylib/twister/twisterlib/harness.py" = [ "./scripts/pylib/twister/twisterlib/harness.py" = [
"B009", # https://docs.astral.sh/ruff/rules/get-attr-with-constant
"B904", # https://docs.astral.sh/ruff/rules/raise-without-from-inside-except "B904", # https://docs.astral.sh/ruff/rules/raise-without-from-inside-except
"E501", # https://docs.astral.sh/ruff/rules/line-too-long "E501", # https://docs.astral.sh/ruff/rules/line-too-long
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders "F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders

View file

@ -924,7 +924,7 @@ class HarnessImporter:
if harness_name: if harness_name:
harness_class = getattr(thismodule, harness_name) harness_class = getattr(thismodule, harness_name)
else: else:
harness_class = getattr(thismodule, 'Test') harness_class = thismodule.Test
return harness_class() return harness_class()
except AttributeError as e: except AttributeError as e:
logger.debug(f"harness {harness_name} not implemented: {e}") logger.debug(f"harness {harness_name} not implemented: {e}")