Refactor this messy Python function

Coding agentKINDA1 method

KINDA — AI can help, with a person in the loop.

1 method on the page: 1 prompt.

Use cases

Methods

Paste into a general LLM and refactor a messy Python function while preserving behavior

prompt

LLMPrompt

Prompt
Copied 0
Refactor this messy Python function to be clearer and safer while preserving behavior.

Deliver:
1) Refactored code
2) List of behavior-preserving changes
3) Residual risks / TODOs
4) 3 unit tests (pytest) covering edge cases

CODE:
<<<paste>>>