Skip to content

Commit 306162a

Browse files
committed
chore(text_editor.py): remove debug print statements to clean up code and improve readability
chore(test_text_editor.py): remove debug output from test case to streamline test execution
1 parent 4dd73b8 commit 306162a

File tree

2 files changed

+1
-27
lines changed

2 files changed

+1
-27
lines changed

src/mcp_text_editor/text_editor.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,6 @@ async def edit_file_contents(
375375
target_content = "".join(target_lines)
376376
actual_range_hash = self.calculate_hash(target_content)
377377

378-
# Debug output for hash comparison
379-
print(
380-
f"Debug - Range hash comparison:"
381-
f"\nExpected: {expected_range_hash}"
382-
f"\nActual: {actual_range_hash}"
383-
f"\nContent: {target_content!r}"
384-
f"\nRange: {line_start_zero}:{line_end_zero + 1}"
385-
)
386-
387378
# Compare hashes
388379
# Empty range_hash means explicit insertion
389380
is_insertion = (
@@ -419,11 +410,6 @@ async def edit_file_contents(
419410
# Replace the specified range
420411
lines[line_start_zero : line_end_zero + 1] = new_lines
421412

422-
# Debug output - shows the operation type
423-
print(
424-
f"Applied patch: line_start={line_start} line_end={line_end} is_insertion={is_insertion} contents={patch.contents!r}"
425-
)
426-
427413
# Write the final content back to file
428414
final_content = "".join(lines)
429415
with open(file_path, "w", encoding=encoding) as f:
@@ -453,13 +439,9 @@ async def edit_file_contents(
453439
"content": None,
454440
}
455441
except Exception as e:
456-
import traceback
457-
458-
print(f"Error: {str(e)}")
459-
print(f"Traceback:\n{traceback.format_exc()}")
460442
return {
461443
"result": "error",
462-
"reason": "Unexpected error occurred",
444+
"reason": f"Unexpected error: {str(e)}",
463445
"file_hash": None,
464446
"content": None,
465447
}

tests/test_text_editor.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,6 @@ async def test_edit_file_with_none_line_end(editor, tmp_path):
472472
# Get file hash
473473
content, _, _, file_hash, _, _ = await editor.read_file_contents(str(test_file))
474474

475-
# デバッグ用の出力を追加
476-
patch = {
477-
"line_start": 2,
478-
"line_end": None, # This should replace from line 2 to end
479-
"contents": "new2\nnew3\n",
480-
"range_hash": editor.calculate_hash("line2\nline3\n"),
481-
}
482-
print(f"\nDebug - Patch being sent: {patch}")
483475
# Test replacement with None as line_end
484476
result = await editor.edit_file_contents(
485477
str(test_file),

0 commit comments

Comments
 (0)