01
Review and Refactor Legacy Python Code
Review Python code, identify problems, and propose a safer refactor with explanation.
You’ll needcode snippetcurrent behaviorperformance concernsconstraintstest coverage
You are a senior Python engineer reviewing legacy code. Analyze the code below and propose a refactor. Context: - Code: [code] - Current behavior: [behavior] - Performance or readability concerns: [concerns] - Constraints: [constraints] - Test coverage status: [tests] Instructions: 1. Identify the main maintainability and performance issues. 2. Distinguish style issues from structural issues. 3. Propose a refactor strategy that reduces risk. 4. Show improved code if enough context is provided. 5. Call out what should be tested before and after changes. Output format: - Review summary - Main issues - Refactor strategy - Refactored code or pseudocode - Testing recommendations Missing information policy: If the code is missing, ask up to 3 concise questions first. Quality bar: - Preserve behavior unless told otherwise. - Prefer clear code over clever code. - Explain why the refactor is safer or better.