scripts: Fix twisterlib for ruff - SIM118

This fixes the ruff linting error SIM118 - unnecessary
use of keys().

Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
This commit is contained in:
Lukasz Mrugala 2024-11-27 11:09:51 +00:00 committed by Carles Cufí
commit f07edf3302
4 changed files with 3 additions and 6 deletions

View file

@ -785,7 +785,6 @@
"./scripts/pylib/twister/twisterlib/environment.py" = [ "./scripts/pylib/twister/twisterlib/environment.py" = [
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default "B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default
"E501", # https://docs.astral.sh/ruff/rules/line-too-long "E501", # https://docs.astral.sh/ruff/rules/line-too-long
"SIM118", # https://docs.astral.sh/ruff/rules/in-dict-keys
"UP006", # https://docs.astral.sh/ruff/rules/non-pep585-annotation "UP006", # https://docs.astral.sh/ruff/rules/non-pep585-annotation
"UP021", # https://docs.astral.sh/ruff/rules/replace-universal-newlines "UP021", # https://docs.astral.sh/ruff/rules/replace-universal-newlines
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting "UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
@ -807,7 +806,6 @@
"./scripts/pylib/twister/twisterlib/hardwaremap.py" = [ "./scripts/pylib/twister/twisterlib/hardwaremap.py" = [
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default "B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default
"E501", # https://docs.astral.sh/ruff/rules/line-too-long "E501", # https://docs.astral.sh/ruff/rules/line-too-long
"SIM118", # https://docs.astral.sh/ruff/rules/in-dict-keys
"UP004", # https://docs.astral.sh/ruff/rules/useless-object-inheritance "UP004", # https://docs.astral.sh/ruff/rules/useless-object-inheritance
"UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes "UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting "UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
@ -897,7 +895,6 @@
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders "F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders
"SIM102", # https://docs.astral.sh/ruff/rules/collapsible-if "SIM102", # https://docs.astral.sh/ruff/rules/collapsible-if
"SIM110", # https://docs.astral.sh/ruff/rules/reimplemented-builtin "SIM110", # https://docs.astral.sh/ruff/rules/reimplemented-builtin
"SIM118", # https://docs.astral.sh/ruff/rules/in-dict-keys
"SIM202", # https://docs.astral.sh/ruff/rules/negate-not-equal-op "SIM202", # https://docs.astral.sh/ruff/rules/negate-not-equal-op
"UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes "UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting "UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting

View file

@ -1022,7 +1022,7 @@ class TwisterEnv:
return diff return diff
dict_options = vars(self.options) dict_options = vars(self.options)
dict_default = vars(self.default_options) dict_default = vars(self.default_options)
for k in dict_options.keys(): for k in dict_options:
if k not in dict_default or dict_options[k] != dict_default[k]: if k not in dict_default or dict_options[k] != dict_default[k]:
diff[k] = dict_options[k] diff[k] = dict_options[k]
return diff return diff

View file

@ -120,7 +120,7 @@ class DUT(object):
d = {} d = {}
exclude = ['_available', '_counter', '_failures', 'match'] exclude = ['_available', '_counter', '_failures', 'match']
v = vars(self) v = vars(self)
for k in v.keys(): for k in v:
if k not in exclude and v[k]: if k not in exclude and v[k]:
d[k] = v[k] d[k] = v[k]
return d return d

View file

@ -570,7 +570,7 @@ class TestPlan:
subcases = None subcases = None
ztest_suite_names = None ztest_suite_names = None
for name in parsed_data.scenarios.keys(): for name in parsed_data.scenarios:
suite_dict = parsed_data.get_scenario(name) suite_dict = parsed_data.get_scenario(name)
suite = TestSuite(root, suite_path, name, data=suite_dict, detailed_test_id=self.options.detailed_test_id) suite = TestSuite(root, suite_path, name, data=suite_dict, detailed_test_id=self.options.detailed_test_id)