Skip to content

Commit db60ecc

Browse files
committed
fix some lint
1 parent ad1f127 commit db60ecc

File tree

7 files changed

+15
-97
lines changed

7 files changed

+15
-97
lines changed

ui/components.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def file_input_component(task_counter: int) -> Optional[str]:
719719
# Clean up original file
720720
try:
721721
os.unlink(original_file_path)
722-
except:
722+
except Exception:
723723
pass
724724
return None
725725

@@ -729,7 +729,7 @@ def file_input_component(task_counter: int) -> Optional[str]:
729729
# Clean up original file
730730
try:
731731
os.unlink(original_file_path)
732-
except:
732+
except Exception:
733733
pass
734734

735735
# Display conversion result
@@ -751,7 +751,7 @@ def file_input_component(task_counter: int) -> Optional[str]:
751751
# Clean up original file
752752
try:
753753
os.unlink(original_file_path)
754-
except:
754+
except Exception:
755755
pass
756756
return None
757757

@@ -982,7 +982,7 @@ def results_display_component(result: Dict[str, Any], task_counter: int):
982982
height=300,
983983
key=f"analysis_{task_counter}",
984984
)
985-
except:
985+
except Exception:
986986
st.text_area(
987987
"Analysis Output",
988988
analysis_result,
@@ -1296,9 +1296,6 @@ def enhanced_progress_display_component(
12961296
), # Jump directly to implementation
12971297
]
12981298

1299-
# Create step indicator container
1300-
step_container = st.container()
1301-
13021299
# Display step grid with fixed layout
13031300
# Use a maximum of 8 columns for consistent sizing
13041301
max_cols = 8
@@ -1350,9 +1347,6 @@ def enhanced_progress_display_component(
13501347
# Status text display
13511348
status_text = st.empty()
13521349

1353-
# Real-time information display
1354-
info_text = st.empty()
1355-
13561350
# Display mode information
13571351
if not enable_indexing:
13581352
st.info(

ui/handlers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ def run_async_task(coro):
169169
from streamlit.runtime.scriptrunner.script_run_context import (
170170
SCRIPT_RUN_CONTEXT_ATTR_NAME,
171171
)
172-
import threading
173172

174173
current_ctx = get_script_run_ctx()
175174
context_available = True
@@ -584,7 +583,7 @@ def cleanup_temp_file(input_source: str, input_type: str):
584583
if input_type == "file" and input_source and os.path.exists(input_source):
585584
try:
586585
os.unlink(input_source)
587-
except:
586+
except Exception:
588587
pass
589588

590589

utils/cli_interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def select_file():
168168
# macOS specific settings
169169
try:
170170
root.call("wm", "attributes", ".", "-topmost", True)
171-
except:
171+
except Exception:
172172
pass
173173

174174
# macOS compatible file types
@@ -211,7 +211,7 @@ def select_file():
211211
# Clean up
212212
try:
213213
root.destroy()
214-
except:
214+
except Exception:
215215
pass
216216

217217
return file_path
@@ -221,7 +221,7 @@ def select_file():
221221
try:
222222
if "root" in locals():
223223
root.destroy()
224-
except:
224+
except Exception:
225225
pass
226226

227227
# Print error and suggest alternative

workflows/agents/code_implementation_agent.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,9 @@ async def _track_file_implementation_with_summary(
414414
self.get_files_implemented_count(), # Pass the current file count
415415
)
416416

417-
# self.logger.info(f"Created code summary for implemented file: {file_path}")
417+
self.logger.info(
418+
f"Created code summary for implemented file: {file_path}, summary: {summary[:100]}..."
419+
)
418420
else:
419421
self.logger.warning(
420422
"Missing file path or content for summary generation"
@@ -512,15 +514,14 @@ def _track_file_implementation(self, tool_call: Dict, result: Any):
512514
except Exception as e:
513515
self.logger.warning(f"Failed to track file implementation: {e}")
514516
# Even if tracking fails, try to count based on tool input (but check for duplicates) / 即使跟踪失败,也尝试根据工具输入计数(但检查重复)
515-
517+
516518
file_path = tool_call["input"].get("file_path")
517519
if file_path and file_path not in self.implemented_files_set:
518520
self.implemented_files_set.add(file_path)
519521
self.files_implemented_count += 1
520522
self.logger.info(
521523
f"File implementation counted (emergency fallback): count={self.files_implemented_count}, file={file_path}"
522524
)
523-
524525

525526
def _track_dependency_analysis(self, tool_call: Dict, result: Any):
526527
"""

workflows/agents/memory_agent_concise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ def record_tool_result(
483483
if tool_name == "write_file":
484484
self.last_write_file_detected = True
485485
self.should_clear_memory_next = True
486-
486+
487487
# self.logger.info(f"🔄 WRITE_FILE DETECTED: {file_path} - Memory will be cleared in next round")
488488

489489
# Only record specific tools that provide essential information

workflows/code_implementation_workflow.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ async def _pure_code_implementation_loop(
363363
start_time = time.time()
364364
max_time = 2400 # 40 minutes
365365

366-
367366
# Initialize specialized agents
368367
code_agent = CodeImplementationAgent(
369368
self.mcp_agent, self.logger, self.enable_read_tools
@@ -387,7 +386,6 @@ async def _pure_code_implementation_loop(
387386
# Initialize memory agent with iteration 0
388387
memory_agent.start_new_round(iteration=0)
389388

390-
391389
while iteration < max_iterations:
392390
iteration += 1
393391
elapsed_time = time.time() - start_time
@@ -452,8 +450,6 @@ async def _pure_code_implementation_loop(
452450
if memory_agent.should_trigger_memory_optimization(
453451
messages, code_agent.get_files_implemented_count()
454452
):
455-
456-
457453
# Memory optimization triggered
458454

459455
# Apply concise memory optimization
@@ -462,9 +458,6 @@ async def _pure_code_implementation_loop(
462458
messages = memory_agent.apply_memory_optimization(
463459
current_system_message, messages, files_implemented_count
464460
)
465-
466-
467-
468461

469462
# Memory optimization completed
470463

@@ -481,21 +474,6 @@ async def _pure_code_implementation_loop(
481474
"Analysis loop detected and corrective guidance provided"
482475
)
483476

484-
# Round completed
485-
486-
# # Test summary functionality after every 10 iterations (reduced frequency)
487-
# if iteration % 10 == 0 and code_agent.get_files_implemented_count() > 0:
488-
# self.logger.info(f"🧪 Testing summary functionality at iteration {iteration}")
489-
# optimization_success = await code_agent.test_summary_optimization()
490-
# if optimization_success:
491-
# self.logger.info("✅ Summary optimization working correctly")
492-
# else:
493-
# self.logger.warning("⚠️ Summary optimization may not be working")
494-
495-
# Update memory agent state with current file implementations
496-
files_implemented = code_agent.get_files_implemented_count()
497-
# memory_agent.sync_with_code_agent(files_implemented)
498-
499477
# Record file implementations in memory agent (for the current round)
500478
for file_info in code_agent.get_implementation_summary()["completed_files"]:
501479
memory_agent.record_file_implementation(file_info["file"])
@@ -564,7 +542,7 @@ async def _initialize_mcp_agent(self, code_directory: str):
564542
if self.mcp_agent:
565543
try:
566544
await self.mcp_agent.__aexit__(None, None, None)
567-
except:
545+
except Exception:
568546
pass
569547
self.mcp_agent = None
570548
raise

workflows/code_implementation_workflow_index.py

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,6 @@ async def _pure_code_implementation_loop(
364364
start_time = time.time()
365365
max_time = 2400 # 40 minutes
366366

367-
# Sliding window configuration
368-
WINDOW_SIZE = 1
369-
SUMMARY_TRIGGER = 8
370-
371367
# Initialize specialized agents
372368
code_agent = CodeImplementationAgent(
373369
self.mcp_agent, self.logger, self.enable_read_tools
@@ -391,11 +387,6 @@ async def _pure_code_implementation_loop(
391387
# Initialize memory agent with iteration 0
392388
memory_agent.start_new_round(iteration=0)
393389

394-
# Preserve initial plan (never compressed)
395-
initial_plan_message = messages[0] if messages else None
396-
397-
# Initial setup logging removed
398-
399390
while iteration < max_iterations:
400391
iteration += 1
401392
elapsed_time = time.time() - start_time
@@ -443,14 +434,6 @@ async def _pure_code_implementation_loop(
443434
)
444435

445436
# NEW LOGIC: Check if write_file was called and trigger memory optimization immediately
446-
write_file_detected = any(
447-
tool_call["name"] == "write_file"
448-
for tool_call in response["tool_calls"]
449-
)
450-
# if write_file_detected:
451-
# self.logger.info(f"🔄 write_file detected - preparing memory optimization for next round")
452-
453-
# Tool results logged via standard logger only
454437

455438
# Determine guidance based on results
456439
has_error = self._check_tool_results_for_errors(tool_results)
@@ -468,27 +451,12 @@ async def _pure_code_implementation_loop(
468451
if memory_agent.should_trigger_memory_optimization(
469452
messages, code_agent.get_files_implemented_count()
470453
):
471-
# Capture messages before optimization
472-
messages_before_optimization = messages.copy()
473-
messages_before_count = len(messages)
474-
475-
# Memory optimization triggered
476-
477454
# Apply concise memory optimization
478455
files_implemented_count = code_agent.get_files_implemented_count()
479456
current_system_message = code_agent.get_system_prompt()
480457
messages = memory_agent.apply_memory_optimization(
481458
current_system_message, messages, files_implemented_count
482459
)
483-
messages_after_count = len(messages)
484-
485-
compression_ratio = (
486-
(messages_before_count - messages_after_count)
487-
/ messages_before_count
488-
* 100
489-
if messages_before_count > 0
490-
else 0
491-
)
492460

493461
# Memory optimization completed
494462

@@ -507,19 +475,6 @@ async def _pure_code_implementation_loop(
507475

508476
# Round completed
509477

510-
# # Test summary functionality after every 10 iterations (reduced frequency)
511-
# if iteration % 10 == 0 and code_agent.get_files_implemented_count() > 0:
512-
# self.logger.info(f"🧪 Testing summary functionality at iteration {iteration}")
513-
# optimization_success = await code_agent.test_summary_optimization()
514-
# if optimization_success:
515-
# self.logger.info("✅ Summary optimization working correctly")
516-
# else:
517-
# self.logger.warning("⚠️ Summary optimization may not be working")
518-
519-
# Update memory agent state with current file implementations
520-
files_implemented = code_agent.get_files_implemented_count()
521-
# memory_agent.sync_with_code_agent(files_implemented)
522-
523478
# Record file implementations in memory agent (for the current round)
524479
for file_info in code_agent.get_implementation_summary()["completed_files"]:
525480
memory_agent.record_file_implementation(file_info["file"])
@@ -549,21 +504,12 @@ async def _pure_code_implementation_loop(
549504
"Emergency message trim - applying concise memory optimization"
550505
)
551506

552-
# Capture messages before emergency optimization
553-
messages_before_emergency = messages.copy()
554-
messages_before_count = len(messages)
555-
556-
# Emergency memory optimization triggered
557-
558507
# Apply emergency memory optimization
559508
current_system_message = code_agent.get_system_prompt()
560509
files_implemented_count = code_agent.get_files_implemented_count()
561510
messages = memory_agent.apply_memory_optimization(
562511
current_system_message, messages, files_implemented_count
563512
)
564-
messages_after_count = len(messages)
565-
566-
# Emergency optimization completed
567513

568514
return await self._generate_pure_code_final_report_with_concise_agents(
569515
iteration, time.time() - start_time, code_agent, memory_agent
@@ -598,7 +544,7 @@ async def _initialize_mcp_agent(self, code_directory: str):
598544
if self.mcp_agent:
599545
try:
600546
await self.mcp_agent.__aexit__(None, None, None)
601-
except:
547+
except Exception:
602548
pass
603549
self.mcp_agent = None
604550
raise

0 commit comments

Comments
 (0)