From 43638640123f3487cd40253935827b190497bfdf Mon Sep 17 00:00:00 2001 From: Timmy Date: Tue, 21 Apr 2026 07:33:29 -0400 Subject: [PATCH] fix: 3 syntax errors in perf_bottleneck_finder.py (closes #211) - Line 116: escaped quotes in regex pattern for file write detection - Line 509: split newline join return statement - Line 523: moved global declaration before first use All 25 test_perf_bottleneck_finder tests pass. python3 -m py_compile succeeds. --- scripts/perf_bottleneck_finder.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/perf_bottleneck_finder.py b/scripts/perf_bottleneck_finder.py index e40ad6a..daa3171 100644 --- a/scripts/perf_bottleneck_finder.py +++ b/scripts/perf_bottleneck_finder.py @@ -113,7 +113,7 @@ def find_slow_tests_by_scan(repo_path: str) -> List[Bottleneck]: (r"time\.sleep\((\d+(?:\.\d+)?)\)", "Contains time.sleep() — consider using mock or async wait"), (r"subprocess\.run\(.*timeout=(\d+)", "Subprocess with timeout — may block test"), (r"requests\.(get|post|put|delete)\(", "Real HTTP call — mock with responses or httpretty"), - (r"open\([^)]*['"]w['"]", "File I/O in test — use tmp_path fixture"), + (r"open\([^)]*['\"]w['\"]\)", "File I/O in test — use tmp_path fixture"), ] for root, dirs, files in os.walk(repo_path): @@ -506,13 +506,13 @@ def format_markdown(report: PerfReport) -> str: lines.append(f"- {icon} {b.name}{loc} — ~{b.duration_s:.1f}s — {b.recommendation}") lines.append(f"") - return " -".join(lines) + return "\n".join(lines) # ── Main ─────────────────────────────────────────────────────────── def main(): + global SLOW_TEST_THRESHOLD_S parser = argparse.ArgumentParser(description="Performance Bottleneck Finder") parser.add_argument("--repo", default=".", help="Path to repository to analyze") parser.add_argument("--json", action="store_true", help="Output as JSON") @@ -521,7 +521,6 @@ def main(): help="Slow test threshold in seconds") args = parser.parse_args() - global SLOW_TEST_THRESHOLD_S SLOW_TEST_THRESHOLD_S = args.threshold if not os.path.isdir(args.repo):