What problem does it solve?
Helps simplify and refactor Python code that suffers from duplicated logic, deep nesting, long if/elif chains, excessive boilerplate, or meaningless intermediate variables while strictly preserving original behavior, public interfaces, exception semantics, and test outcomes.
Core Features & Use Cases
- Behavior-preserving refactoring guidance: concrete patterns to remove duplication, extract helpers, and reduce nesting without altering return values or side effects.
- Readable replacements: recommend idiomatic constructs such as guard clauses, dictionary mappings, comprehensions, dataclasses, and context managers where appropriate.
- Validation and safety checklist: scope constraints, a pre/post refactor checklist, and verification steps using tests, ruff formatting/checks, and basedpyright type checks.
- Typical scenarios: local file diffs, targeted function simplification, and removing boilerplate in data classes or repetitive validation logic.
Quick Start
Simplify and refactor the provided Python function to remove duplicate validation and reduce nesting while preserving all behavior and ensuring tests still pass.