scripts: Fix twisterlib for ruff - B028
This fixes ruff linting error B028, where warnings.warn() lacked explicit stacklevel parameter. Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
This commit is contained in:
parent
0df8240b49
commit
9b128a24e2
4 changed files with 17 additions and 10 deletions
|
@ -763,7 +763,6 @@
|
|||
"UP032", # https://docs.astral.sh/ruff/rules/f-string
|
||||
]
|
||||
"./scripts/pylib/twister/twisterlib/config_parser.py" = [
|
||||
"B028", # https://docs.astral.sh/ruff/rules/no-explicit-stacklevel
|
||||
"UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation
|
||||
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
|
||||
]
|
||||
|
|
|
@ -130,7 +130,9 @@ class TwisterConfigParser:
|
|||
if len(vs) > 1:
|
||||
warnings.warn(
|
||||
"Space-separated lists are deprecated, use YAML lists instead",
|
||||
DeprecationWarning)
|
||||
DeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
|
||||
if len(typestr) > 4 and typestr[4] == ":":
|
||||
return [self._cast_value(vsi, typestr[5:]) for vsi in vs]
|
||||
|
@ -148,7 +150,9 @@ class TwisterConfigParser:
|
|||
if len(vs) > 1:
|
||||
warnings.warn(
|
||||
"Space-separated lists are deprecated, use YAML lists instead",
|
||||
DeprecationWarning)
|
||||
DeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
|
||||
if len(typestr) > 3 and typestr[3] == ":":
|
||||
return {self._cast_value(vsi, typestr[4:]) for vsi in vs}
|
||||
|
@ -243,7 +247,8 @@ class TwisterConfigParser:
|
|||
"in extra_args. This feature is deprecated and will soon "
|
||||
"result in an error. Use extra_conf_files, extra_overlay_confs "
|
||||
"or extra_dtc_overlay_files YAML fields instead",
|
||||
DeprecationWarning
|
||||
DeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
|
||||
for k, kinfo in self.testsuite_valid_keys.items():
|
||||
|
|
|
@ -160,7 +160,7 @@ def test_cast_value(zephyr_base, value, typestr, expected, expected_warning):
|
|||
result = parser._cast_value(value, typestr)
|
||||
assert result == expected
|
||||
if expected_warning:
|
||||
warn_mock.assert_called_once_with(*expected_warning)
|
||||
warn_mock.assert_called_once_with(*expected_warning, stacklevel=mock.ANY)
|
||||
else:
|
||||
warn_mock.assert_not_called()
|
||||
|
||||
|
|
|
@ -65,11 +65,14 @@ def test_testsuite_config_files():
|
|||
|
||||
# CONF_FILE, DTC_OVERLAY_FILE, OVERLAY_CONFIG fields should be stripped out
|
||||
# of extra_args. Other fields should remain untouched.
|
||||
warn_mock.assert_called_once_with("Do not specify CONF_FILE, OVERLAY_CONFIG, or "
|
||||
"DTC_OVERLAY_FILE in extra_args. This feature is "
|
||||
"deprecated and will soon result in an error. Use "
|
||||
"extra_conf_files, extra_overlay_confs or "
|
||||
"extra_dtc_overlay_files YAML fields instead", DeprecationWarning)
|
||||
warn_mock.assert_called_once_with(
|
||||
"Do not specify CONF_FILE, OVERLAY_CONFIG, or DTC_OVERLAY_FILE in extra_args."
|
||||
" This feature is deprecated and will soon result in an error."
|
||||
" Use extra_conf_files, extra_overlay_confs"
|
||||
" or extra_dtc_overlay_files YAML fields instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
|
||||
assert scenario["extra_args"] == ["UNRELATED1=abc", "UNRELATED2=xyz"]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue