scripts: Fix twisterlib for ruff - B904
This fixes ruff linting error B904, where an error raised inside an except clause does not specify from where it should start. Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
This commit is contained in:
parent
29cdac06a0
commit
9584eaee2d
6 changed files with 12 additions and 16 deletions
|
@ -764,7 +764,6 @@
|
||||||
]
|
]
|
||||||
"./scripts/pylib/twister/twisterlib/config_parser.py" = [
|
"./scripts/pylib/twister/twisterlib/config_parser.py" = [
|
||||||
"B028", # https://docs.astral.sh/ruff/rules/no-explicit-stacklevel
|
"B028", # https://docs.astral.sh/ruff/rules/no-explicit-stacklevel
|
||||||
"B904", # https://docs.astral.sh/ruff/rules/raise-without-from-inside-except
|
|
||||||
"UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation
|
"UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation
|
||||||
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
|
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
|
||||||
]
|
]
|
||||||
|
@ -799,7 +798,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" = [
|
||||||
"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
|
||||||
"F811", # https://docs.astral.sh/ruff/rules/redefined-while-unused
|
"F811", # https://docs.astral.sh/ruff/rules/redefined-while-unused
|
||||||
|
@ -843,7 +841,6 @@
|
||||||
]
|
]
|
||||||
"./scripts/pylib/twister/twisterlib/testinstance.py" = [
|
"./scripts/pylib/twister/twisterlib/testinstance.py" = [
|
||||||
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default
|
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default
|
||||||
"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
|
||||||
"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
|
||||||
|
@ -851,7 +848,6 @@
|
||||||
"./scripts/pylib/twister/twisterlib/testplan.py" = [
|
"./scripts/pylib/twister/twisterlib/testplan.py" = [
|
||||||
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default
|
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default
|
||||||
"B023", # https://docs.astral.sh/ruff/rules/function-uses-loop-variable
|
"B023", # https://docs.astral.sh/ruff/rules/function-uses-loop-variable
|
||||||
"B904", # https://docs.astral.sh/ruff/rules/raise-without-from-inside-except
|
|
||||||
"E402", # https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file
|
"E402", # https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file
|
||||||
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
|
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
|
||||||
"F401", # https://docs.astral.sh/ruff/rules/unused-import
|
"F401", # https://docs.astral.sh/ruff/rules/unused-import
|
||||||
|
@ -862,7 +858,6 @@
|
||||||
]
|
]
|
||||||
"./scripts/pylib/twister/twisterlib/testsuite.py" = [
|
"./scripts/pylib/twister/twisterlib/testsuite.py" = [
|
||||||
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default
|
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default
|
||||||
"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
|
||||||
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
|
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
|
||||||
"UP032", # https://docs.astral.sh/ruff/rules/f-string
|
"UP032", # https://docs.astral.sh/ruff/rules/f-string
|
||||||
|
|
|
@ -267,6 +267,7 @@ class TwisterConfigParser:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ConfigurationError(
|
raise ConfigurationError(
|
||||||
self.filename, "bad %s value '%s' for key '%s' in name '%s'" %
|
self.filename, "bad %s value '%s' for key '%s' in name '%s'" %
|
||||||
(kinfo["type"], d[k], k, name))
|
(kinfo["type"], d[k], k, name)
|
||||||
|
) from None
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
|
@ -82,8 +82,8 @@ class Harness:
|
||||||
try:
|
try:
|
||||||
key = value.name if isinstance(value, Enum) else value
|
key = value.name if isinstance(value, Enum) else value
|
||||||
self._status = TwisterStatus[key]
|
self._status = TwisterStatus[key]
|
||||||
except KeyError:
|
except KeyError as err:
|
||||||
raise StatusAttributeError(self.__class__, value)
|
raise StatusAttributeError(self.__class__, value) from err
|
||||||
|
|
||||||
def configure(self, instance):
|
def configure(self, instance):
|
||||||
self.instance = instance
|
self.instance = instance
|
||||||
|
|
|
@ -110,8 +110,8 @@ class TestInstance:
|
||||||
try:
|
try:
|
||||||
key = value.name if isinstance(value, Enum) else value
|
key = value.name if isinstance(value, Enum) else value
|
||||||
self._status = TwisterStatus[key]
|
self._status = TwisterStatus[key]
|
||||||
except KeyError:
|
except KeyError as err:
|
||||||
raise StatusAttributeError(self.__class__, value)
|
raise StatusAttributeError(self.__class__, value) from err
|
||||||
|
|
||||||
def add_filter(self, reason, filter_type):
|
def add_filter(self, reason, filter_type):
|
||||||
self.filters.append({'type': filter_type, 'reason': reason })
|
self.filters.append({'type': filter_type, 'reason': reason })
|
||||||
|
|
|
@ -255,8 +255,8 @@ class TestPlan:
|
||||||
s = self.options.subset
|
s = self.options.subset
|
||||||
try:
|
try:
|
||||||
subset, sets = (int(x) for x in s.split("/"))
|
subset, sets = (int(x) for x in s.split("/"))
|
||||||
except ValueError:
|
except ValueError as err:
|
||||||
raise TwisterRuntimeError("Bad subset value.")
|
raise TwisterRuntimeError("Bad subset value.") from err
|
||||||
|
|
||||||
if subset > sets:
|
if subset > sets:
|
||||||
raise TwisterRuntimeError("subset should not exceed the total number of sets")
|
raise TwisterRuntimeError("subset should not exceed the total number of sets")
|
||||||
|
|
|
@ -377,8 +377,8 @@ class TestCase(DisablePyTestCollectionMixin):
|
||||||
try:
|
try:
|
||||||
key = value.name if isinstance(value, Enum) else value
|
key = value.name if isinstance(value, Enum) else value
|
||||||
self._status = TwisterStatus[key]
|
self._status = TwisterStatus[key]
|
||||||
except KeyError:
|
except KeyError as err:
|
||||||
raise StatusAttributeError(self.__class__, value)
|
raise StatusAttributeError(self.__class__, value) from err
|
||||||
|
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
return self.name < other.name
|
return self.name < other.name
|
||||||
|
@ -443,8 +443,8 @@ class TestSuite(DisablePyTestCollectionMixin):
|
||||||
try:
|
try:
|
||||||
key = value.name if isinstance(value, Enum) else value
|
key = value.name if isinstance(value, Enum) else value
|
||||||
self._status = TwisterStatus[key]
|
self._status = TwisterStatus[key]
|
||||||
except KeyError:
|
except KeyError as err:
|
||||||
raise StatusAttributeError(self.__class__, value)
|
raise StatusAttributeError(self.__class__, value) from err
|
||||||
|
|
||||||
def load(self, data):
|
def load(self, data):
|
||||||
for k, v in data.items():
|
for k, v in data.items():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue