Context tile for pidge notification library v3 - async API with NotificationClient, Message, and dispatch pattern
99
Quality
99%
Does it follow best practices?
Impact
100%
2.85xAverage score across 3 eval scenarios
Passed
No known issues
A SaaS platform's password reset flow uses the pidge notification library to deliver reset-link emails. The infrastructure team has reported that during peak traffic periods, some notifications fail due to momentary network hiccups between the application and the pidge API — these are short-lived and typically succeed on a second or third attempt. However, other failures (like emails sent to deactivated or malformed addresses) are permanent and wasting retries only delays the response to the user.
The team needs a robust send_password_reset async function that wraps the pidge dispatch call with smart retry behaviour: retrying on transient failures while giving up immediately on permanent ones. The function should be production-ready — logging what happened at each stage and making the outcome clear to the caller.
The pidge library (pip install pidge) is already available. The PIDGE_API_KEY environment variable will be set at runtime.
Produce a Python file password_reset_notify.py containing:
An async function send_password_reset(email: str, reset_url: str) -> dict that:
A brief if __name__ == "__main__": block that demonstrates calling the function with a sample email and URL (using asyncio.run).
Include all imports and make the file self-contained.