Skip to content

Commit 07ffac0

Browse files
style: auto-fix linting issues
Convert f-string logging to lazy % formatting (G004) and replace try-except-pass with contextlib.suppress (SIM105). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 29c9199 commit 07ffac0

3 files changed

Lines changed: 18 additions & 15 deletions

File tree

codeflash/languages/java/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,13 @@ def check_dependencies(deps_element, ns):
205205

206206
if group_id == "org.junit.jupiter" or (artifact_id and "junit-jupiter" in artifact_id):
207207
has_junit5 = True
208-
logger.debug(f"Found JUnit 5 dependency: {group_id}:{artifact_id}")
208+
logger.debug("Found JUnit 5 dependency: %s:%s", group_id, artifact_id)
209209
elif group_id == "junit" and artifact_id == "junit":
210210
has_junit4 = True
211-
logger.debug(f"Found JUnit 4 dependency: {group_id}:{artifact_id}")
211+
logger.debug("Found JUnit 4 dependency: %s:%s", group_id, artifact_id)
212212
elif group_id == "org.testng":
213213
has_testng = True
214-
logger.debug(f"Found TestNG dependency: {group_id}:{artifact_id}")
214+
logger.debug("Found TestNG dependency: %s:%s", group_id, artifact_id)
215215

216216
try:
217217
tree = ET.parse(pom_path)
@@ -220,20 +220,20 @@ def check_dependencies(deps_element, ns):
220220
# Handle namespace
221221
ns = {"m": "http://maven.apache.org/POM/4.0.0"}
222222

223-
logger.debug(f"Checking pom.xml at {pom_path}")
223+
logger.debug("Checking pom.xml at %s", pom_path)
224224

225225
# Search for direct dependencies
226226
for deps_path in ["dependencies", "m:dependencies"]:
227227
deps = root.find(deps_path, ns) if "m:" in deps_path else root.find(deps_path)
228228
if deps is not None:
229-
logger.debug(f"Found dependencies section in {pom_path}")
229+
logger.debug("Found dependencies section in %s", pom_path)
230230
check_dependencies(deps, ns)
231231

232232
# Also check dependencyManagement section (for multi-module projects)
233233
for dep_mgmt_path in ["dependencyManagement", "m:dependencyManagement"]:
234234
dep_mgmt = root.find(dep_mgmt_path, ns) if "m:" in dep_mgmt_path else root.find(dep_mgmt_path)
235235
if dep_mgmt is not None:
236-
logger.debug(f"Found dependencyManagement section in {pom_path}")
236+
logger.debug("Found dependencyManagement section in %s", pom_path)
237237
for deps_path in ["dependencies", "m:dependencies"]:
238238
deps = dep_mgmt.find(deps_path, ns) if "m:" in deps_path else dep_mgmt.find(deps_path)
239239
if deps is not None:
@@ -249,15 +249,15 @@ def check_dependencies(deps_element, ns):
249249
for submodule_name in ["test", "tests", "src/test", "testing"]:
250250
submodule_pom = project_root / submodule_name / "pom.xml"
251251
if submodule_pom.exists():
252-
logger.debug(f"Checking submodule pom at {submodule_pom}")
252+
logger.debug("Checking submodule pom at %s", submodule_pom)
253253
sub_junit5, sub_junit4, sub_testng = _detect_test_deps_from_pom(project_root / submodule_name)
254254
has_junit5 = has_junit5 or sub_junit5
255255
has_junit4 = has_junit4 or sub_junit4
256256
has_testng = has_testng or sub_testng
257257
if has_junit5 or has_junit4 or has_testng:
258258
break
259259

260-
logger.debug(f"Test framework detection result: junit5={has_junit5}, junit4={has_junit4}, testng={has_testng}")
260+
logger.debug("Test framework detection result: junit5=%s, junit4=%s, testng=%s", has_junit5, has_junit4, has_testng)
261261
return has_junit5, has_junit4, has_testng
262262

263263

codeflash/languages/java/instrumentation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def _is_inside_complex_expression(node) -> bool:
127127
"parenthesized_expression",
128128
"instanceof_expression",
129129
}:
130-
logger.debug(f"Found complex expression parent: {current.type}")
130+
logger.debug("Found complex expression parent: %s", current.type)
131131
return True
132132

133133
current = current.parent
@@ -734,7 +734,7 @@ def collect_target_calls(node, wrapper_bytes: bytes, func: str, out) -> None:
734734
if not _is_inside_lambda(node) and not _is_inside_complex_expression(node):
735735
out.append(node)
736736
else:
737-
logger.debug(f"Skipping instrumentation of {func} inside lambda or complex expression")
737+
logger.debug("Skipping instrumentation of %s inside lambda or complex expression", func)
738738
for child in node.children:
739739
collect_target_calls(child, wrapper_bytes, func, out)
740740

codeflash/languages/java/test_runner.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from __future__ import annotations
88

9+
import contextlib
910
import logging
1011
import os
1112
import re
@@ -570,7 +571,7 @@ def _get_test_classpath(
570571
if module_dir.is_dir() and module_dir.name != test_module:
571572
module_classes = module_dir / "target" / "classes"
572573
if module_classes.exists():
573-
logger.debug(f"Adding multi-module classpath: {module_classes}")
574+
logger.debug("Adding multi-module classpath: %s", module_classes)
574575
cp_parts.append(str(module_classes))
575576

576577
# Add JUnit Platform Console Standalone JAR if not already on classpath.
@@ -612,7 +613,7 @@ def _find_junit_console_standalone() -> Path | None:
612613
mvn = find_maven_executable()
613614
if mvn:
614615
logger.debug("Console standalone not found in cache, downloading via Maven")
615-
try:
616+
with contextlib.suppress(subprocess.TimeoutExpired, Exception):
616617
subprocess.run(
617618
[
618619
mvn,
@@ -626,14 +627,16 @@ def _find_junit_console_standalone() -> Path | None:
626627
text=True,
627628
timeout=30,
628629
)
629-
except (subprocess.TimeoutExpired, Exception):
630-
pass
631630
if not m2_base.exists():
632631
return None
633632

634633
# Find the latest version available
635634
try:
636-
versions = sorted([d for d in m2_base.iterdir() if d.is_dir()], key=lambda d: tuple(int(x) for x in d.name.split('.') if x.isdigit()), reverse=True)
635+
versions = sorted(
636+
[d for d in m2_base.iterdir() if d.is_dir()],
637+
key=lambda d: tuple(int(x) for x in d.name.split(".") if x.isdigit()),
638+
reverse=True,
639+
)
637640
for version_dir in versions:
638641
jar = version_dir / f"junit-platform-console-standalone-{version_dir.name}.jar"
639642
if jar.exists():

0 commit comments

Comments
 (0)