Funciona hoy, pero se degrada rápido
- helpers gigantes y responsabilidades mezcladas
- errores ad hoc y casi nada de tipado
- tests opcionales o inexistentes
def process(data):
result = []
for item in data:
if item.get("active"):
result.append(item["email"].lower())
return resultMejores defaults para mantenerlo vivo
- módulos pequeños y límites claros
- type hints útiles y errores más previsibles
- debugging y pruebas planteados desde el inicio
from collections.abc import Iterable
def collect_active_emails(users: Iterable[dict[str, object]]) -> list[str]:
emails: list[str] = []
for user in users:
if user.get("active") is True and isinstance(user.get("email"), str):
emails.append(user["email"].lower())
return emailsResultado: menos deuda accidental cuando el agente toca APIs, automatización o notebooks.
OpenAI Codex




