Skip to content

Commit 7746a97

Browse files
LukaszMrugalacarlescufi
authored andcommitted
scripts: Fix twisterlib for ruff - F541
This fixes ruff linting error F541, where an fstring is used when a normal string would suffice. Signed-off-by: Lukasz Mrugala <[email protected]>
1 parent 8353a6c commit 7746a97

File tree

7 files changed

+10
-16
lines changed

7 files changed

+10
-16
lines changed

.ruff-excludes.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,6 @@
766766
]
767767
"./scripts/pylib/twister/twisterlib/coverage.py" = [
768768
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
769-
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders
770769
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
771770
"UP032", # https://docs.astral.sh/ruff/rules/f-string
772771
]
@@ -776,7 +775,6 @@
776775
]
777776
"./scripts/pylib/twister/twisterlib/handlers.py" = [
778777
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
779-
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders
780778
"UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation
781779
"UP030", # https://docs.astral.sh/ruff/rules/format-literals
782780
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
@@ -788,7 +786,6 @@
788786
]
789787
"./scripts/pylib/twister/twisterlib/harness.py" = [
790788
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
791-
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders
792789
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
793790
"UP032", # https://docs.astral.sh/ruff/rules/f-string
794791
]
@@ -802,13 +799,11 @@
802799
]
803800
"./scripts/pylib/twister/twisterlib/reports.py" = [
804801
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
805-
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders
806802
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
807803
"UP032", # https://docs.astral.sh/ruff/rules/f-string
808804
]
809805
"./scripts/pylib/twister/twisterlib/runner.py" = [
810806
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
811-
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders
812807
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
813808
"UP032", # https://docs.astral.sh/ruff/rules/f-string
814809
]
@@ -824,7 +819,6 @@
824819
"E402", # https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file
825820
"E501", # https://docs.astral.sh/ruff/rules/line-too-long
826821
"F401", # https://docs.astral.sh/ruff/rules/unused-import
827-
"F541", # https://docs.astral.sh/ruff/rules/f-string-missing-placeholders
828822
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
829823
"UP032", # https://docs.astral.sh/ruff/rules/f-string
830824
]

scripts/pylib/twister/twisterlib/coverage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def run_coverage(testplan, options):
413413
elif os.path.exists(zephyr_sdk_gcov_tool):
414414
gcov_tool = zephyr_sdk_gcov_tool
415415
else:
416-
logger.error(f"Can't find a suitable gcov tool. Use --gcov-tool or set ZEPHYR_SDK_INSTALL_DIR.")
416+
logger.error("Can't find a suitable gcov tool. Use --gcov-tool or set ZEPHYR_SDK_INSTALL_DIR.")
417417
sys.exit(1)
418418
else:
419419
gcov_tool = str(options.gcov_tool)

scripts/pylib/twister/twisterlib/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def _missing_suite_name(self, expected_suite_names, handler_time):
137137
self.instance.execution_time = handler_time
138138
for tc in self.instance.testcases:
139139
tc.status = TwisterStatus.FAIL
140-
self.instance.reason = f"Testsuite mismatch"
140+
self.instance.reason = "Testsuite mismatch"
141141
logger.debug("Test suite names were not printed or some of them in " \
142142
"output do not correspond with expected: %s",
143143
str(expected_suite_names))

scripts/pylib/twister/twisterlib/harness.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def run_robot_test(self, command, handler):
201201
command.append(f'{v}')
202202

203203
if self.path is None:
204-
raise PytestHarnessException(f'The parameter robot_testsuite is mandatory')
204+
raise PytestHarnessException('The parameter robot_testsuite is mandatory')
205205

206206
if isinstance(self.path, list):
207207
for suite in self.path:

scripts/pylib/twister/twisterlib/reports.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def xunit_testcase(eleTestsuite, name, classname, status: TwisterStatus, ts_stat
106106
else:
107107
if status == TwisterStatus.NONE:
108108
logger.debug(f"{name}: No status")
109-
ET.SubElement(eleTestcase, ReportStatus.SKIP, type=f"untested", message="No results captured, testsuite misconfiguration?")
109+
ET.SubElement(eleTestcase, ReportStatus.SKIP, type="untested", message="No results captured, testsuite misconfiguration?")
110110
else:
111111
logger.error(f"{name}: Unknown status '{status}'")
112112

@@ -523,7 +523,7 @@ def synopsis(self):
523523
log_txt = f"The following issues were found (showing the all {count} items):"
524524
elif self.env.options.report_summary:
525525
count = self.env.options.report_summary
526-
log_txt = f"The following issues were found "
526+
log_txt = "The following issues were found "
527527
if count > self.instance_fail_count:
528528
log_txt += f"(presenting {self.instance_fail_count} out of the {count} items requested):"
529529
else:
@@ -551,7 +551,7 @@ def synopsis(self):
551551
break
552552
if cnt == 0 and self.env.options.report_summary is not None:
553553
logger.info("-+" * 40)
554-
logger.info(f"No errors/fails found")
554+
logger.info("No errors/fails found")
555555

556556
if cnt and example_instance:
557557
cwd_rel_path = os.path.relpath(example_instance.testsuite.source_dir, start=os.getcwd())
@@ -563,7 +563,7 @@ def synopsis(self):
563563
logger.info("")
564564
logger.info(f"west twister -p {example_instance.platform.name} -s {example_instance.testsuite.name}"
565565
f"{extra_parameters}")
566-
logger.info(f"or with west:")
566+
logger.info("or with west:")
567567
logger.info(f"west build -p -b {example_instance.platform.name} {cwd_rel_path} -T {example_instance.testsuite.id}")
568568
logger.info("-+" * 40)
569569

scripts/pylib/twister/twisterlib/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ def process(self, pipeline, done, message, lock, results):
10181018
if self.instance.status == TwisterStatus.NOTRUN:
10191019
run_conditions = f"(run:{self.instance.run}, handler.ready:{self.instance.handler.ready})"
10201020
logger.debug(f"Instance {self.instance.name} can't run {run_conditions}")
1021-
self.instance.add_missing_case_status(TwisterStatus.NOTRUN, f"Nowhere to run")
1021+
self.instance.add_missing_case_status(TwisterStatus.NOTRUN, "Nowhere to run")
10221022
next_op = 'report'
10231023
except StatusAttributeError as sae:
10241024
logger.error(str(sae))

scripts/pylib/twister/twisterlib/testplan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ def apply_filters(self, **kwargs):
786786
if platform_filter:
787787
logger.debug(f"Checking platform filter: {platform_filter}")
788788
# find in aliases and rename
789-
self.verify_platforms_existence(platform_filter, f"platform_filter")
789+
self.verify_platforms_existence(platform_filter, "platform_filter")
790790
for pf in platform_filter:
791791
logger.debug(f"Checking platform in filter: {pf}")
792792
if pf in self.platform_names:
@@ -981,7 +981,7 @@ def apply_filters(self, **kwargs):
981981
# Search and check that all required snippet files are found
982982
for this_snippet in snippet_args['snippets']:
983983
if this_snippet not in found_snippets:
984-
logger.error(f"Can't find snippet '%s' for test '%s'", this_snippet, ts.name)
984+
logger.error("Can't find snippet '%s' for test '%s'", this_snippet, ts.name)
985985
instance.status = TwisterStatus.ERROR
986986
instance.reason = f"Snippet {this_snippet} not found"
987987
missing_snippet = True

0 commit comments

Comments
 (0)