From 667b8d0ce70edd41ec53a148cca3c4ec6392027a Mon Sep 17 00:00:00 2001 From: Fahad Date: Mon, 9 Jun 2025 12:43:59 +0400 Subject: [PATCH] style: apply black formatting to review_pending_changes files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- tests/test_review_pending_changes.py | 1 - tools/review_pending_changes.py | 36 +++++++++++++++------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/tests/test_review_pending_changes.py b/tests/test_review_pending_changes.py index 267f3d9..d60960a 100644 --- a/tests/test_review_pending_changes.py +++ b/tests/test_review_pending_changes.py @@ -240,7 +240,6 @@ class TestReviewPendingChangesTool: (True, "diff --git a/file2.py..."), # diff for file2.py ] - request = ReviewPendingChangesRequest( path="/absolute/repo/path", focus_on="error handling", diff --git a/tools/review_pending_changes.py b/tools/review_pending_changes.py index 0902c58..f019b44 100644 --- a/tools/review_pending_changes.py +++ b/tools/review_pending_changes.py @@ -118,7 +118,9 @@ class ReviewPendingChanges(BaseTool): all_diffs = [] repo_summaries = [] total_tokens = 0 - max_tokens = MAX_CONTEXT_TOKENS - 50000 # Reserve tokens for prompt and response + max_tokens = ( + MAX_CONTEXT_TOKENS - 50000 + ) # Reserve tokens for prompt and response for repo_path in repositories: repo_name = os.path.basename(repo_path) or "root" @@ -151,9 +153,7 @@ class ReviewPendingChanges(BaseTool): ["diff", "--name-only", f"{request.compare_to}...HEAD"], ) if success and files_output.strip(): - changed_files = [ - f for f in files_output.strip().split("\n") if f - ] + changed_files = [f for f in files_output.strip().split("\n") if f] # Generate per-file diffs for file_path in changed_files: @@ -170,9 +170,11 @@ class ReviewPendingChanges(BaseTool): # Format diff with file header safe_file_name = self._sanitize_filename(file_path) diff_header = f"\n--- BEGIN DIFF: {repo_name} / {file_path} (compare to {request.compare_to}) ---\n" - diff_footer = f"\n--- END DIFF: {repo_name} / {file_path} ---\n" + diff_footer = ( + f"\n--- END DIFF: {repo_name} / {file_path} ---\n" + ) formatted_diff = diff_header + diff + diff_footer - + # Check token limit diff_tokens = estimate_tokens(formatted_diff) if total_tokens + diff_tokens <= max_tokens: @@ -200,11 +202,14 @@ class ReviewPendingChanges(BaseTool): if success and diff.strip(): safe_file_name = self._sanitize_filename(file_path) diff_header = f"\n--- BEGIN DIFF: {repo_name} / {file_path} (staged) ---\n" - diff_footer = f"\n--- END DIFF: {repo_name} / {file_path} ---\n" + diff_footer = ( + f"\n--- END DIFF: {repo_name} / {file_path} ---\n" + ) formatted_diff = diff_header + diff + diff_footer - + # Check token limit from utils import estimate_tokens + diff_tokens = estimate_tokens(formatted_diff) if total_tokens + diff_tokens <= max_tokens: all_diffs.append(formatted_diff) @@ -227,11 +232,14 @@ class ReviewPendingChanges(BaseTool): if success and diff.strip(): safe_file_name = self._sanitize_filename(file_path) diff_header = f"\n--- BEGIN DIFF: {repo_name} / {file_path} (unstaged) ---\n" - diff_footer = f"\n--- END DIFF: {repo_name} / {file_path} ---\n" + diff_footer = ( + f"\n--- END DIFF: {repo_name} / {file_path} ---\n" + ) formatted_diff = diff_header + diff + diff_footer - + # Check token limit from utils import estimate_tokens + diff_tokens = estimate_tokens(formatted_diff) if total_tokens + diff_tokens <= max_tokens: all_diffs.append(formatted_diff) @@ -281,15 +289,11 @@ class ReviewPendingChanges(BaseTool): review_scope.append("staged") if request.include_unstaged: review_scope.append("unstaged") - prompt_parts.append( - f"- Reviewing: {' and '.join(review_scope)} changes" - ) + prompt_parts.append(f"- Reviewing: {' and '.join(review_scope)} changes") # Add repository summary prompt_parts.append(f"\n## Repository Changes Summary\n") - prompt_parts.append( - f"Found {len(repo_summaries)} repositories with changes:\n" - ) + prompt_parts.append(f"Found {len(repo_summaries)} repositories with changes:\n") for idx, summary in enumerate(repo_summaries, 1): prompt_parts.append(f"\n### Repository {idx}: {summary['path']}")