scripts: Fix twisterlib for ruff - SIM401
This fixes the ruff linting error SIM401, where if-else construction is used instead of dict.get(). Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
This commit is contained in:
parent
f07edf3302
commit
a20e395174
3 changed files with 2 additions and 9 deletions
|
@ -768,7 +768,6 @@
|
|||
"./scripts/pylib/twister/twisterlib/config_parser.py" = [
|
||||
"B028", # https://docs.astral.sh/ruff/rules/no-explicit-stacklevel
|
||||
"B904", # https://docs.astral.sh/ruff/rules/raise-without-from-inside-except
|
||||
"SIM401", # https://docs.astral.sh/ruff/rules/if-else-block-instead-of-dict-get
|
||||
"UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation
|
||||
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
|
||||
]
|
||||
|
@ -872,9 +871,6 @@
|
|||
"UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes
|
||||
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
|
||||
]
|
||||
"./scripts/pylib/twister/twisterlib/statuses.py" = [
|
||||
"SIM401", # https://docs.astral.sh/ruff/rules/if-else-block-instead-of-dict-get
|
||||
]
|
||||
"./scripts/pylib/twister/twisterlib/testinstance.py" = [
|
||||
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default
|
||||
"B904", # https://docs.astral.sh/ruff/rules/raise-without-from-inside-except
|
||||
|
|
|
@ -248,10 +248,7 @@ class TwisterConfigParser:
|
|||
|
||||
for k, kinfo in self.testsuite_valid_keys.items():
|
||||
if k not in d:
|
||||
if "required" in kinfo:
|
||||
required = kinfo["required"]
|
||||
else:
|
||||
required = False
|
||||
required = kinfo.get("required", False)
|
||||
|
||||
if required:
|
||||
raise ConfigurationError(
|
||||
|
|
|
@ -35,7 +35,7 @@ class TwisterStatus(str, Enum):
|
|||
TwisterStatus.STARTED: Fore.MAGENTA,
|
||||
TwisterStatus.NONE: Fore.MAGENTA
|
||||
}
|
||||
return status2color[status] if status in status2color else Fore.RESET
|
||||
return status2color.get(status, Fore.RESET)
|
||||
|
||||
# All statuses below this comment can be used for TestCase
|
||||
BLOCK = 'blocked'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue