From 08b6d5e2b69f03373f058f38bb69936219a6a937 Mon Sep 17 00:00:00 2001 From: Gabriel Miranda Date: Mon, 17 Aug 2026 17:15:15 -0300 Subject: [PATCH] fix: allow null contact first_name and last_name NotRequired[str] said the key may be absent but promised a real str when present. The API returns null, which is the case that type ruled out. Co-Authored-By: Claude Opus 5 (1M context) --- resend/contacts/_contact.py | 10 +++++----- resend/webhooks/_webhook_event.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/resend/contacts/_contact.py b/resend/contacts/_contact.py index 4089e43..83e6eeb 100644 --- a/resend/contacts/_contact.py +++ b/resend/contacts/_contact.py @@ -1,4 +1,4 @@ -from typing import Any, Dict +from typing import Any, Dict, Optional from typing_extensions import NotRequired, TypedDict @@ -12,13 +12,13 @@ class Contact(TypedDict): """ The email of the contact. """ - first_name: NotRequired[str] + first_name: Optional[str] """ - The first name of the contact. + The first name of the contact. None when the contact has no first name. """ - last_name: NotRequired[str] + last_name: Optional[str] """ - The last name of the contact. + The last name of the contact. None when the contact has no last name. """ created_at: str """ diff --git a/resend/webhooks/_webhook_event.py b/resend/webhooks/_webhook_event.py index 42d66cf..34c8b1b 100644 --- a/resend/webhooks/_webhook_event.py +++ b/resend/webhooks/_webhook_event.py @@ -277,13 +277,13 @@ class ContactEventData(TypedDict): """ Whether the contact is unsubscribed. """ - first_name: NotRequired[str] + first_name: NotRequired[Optional[str]] """ - The contact's first name. + The contact's first name. None when the contact has no first name. """ - last_name: NotRequired[str] + last_name: NotRequired[Optional[str]] """ - The contact's last name. + The contact's last name. None when the contact has no last name. """