From 7459ac3633b3df40c391fe7adf01ac8cd95c598e Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 31 Oct 2023 11:33:53 -0700 Subject: [PATCH 1/4] Add types for error object --- stripe/api_resources/error_object.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/stripe/api_resources/error_object.py b/stripe/api_resources/error_object.py index 21249655d..d1bfe167b 100644 --- a/stripe/api_resources/error_object.py +++ b/stripe/api_resources/error_object.py @@ -1,8 +1,26 @@ +from typing import Optional +from stripe.api_resources.payment_intent import PaymentIntent +from stripe.api_resources.setup_intent import SetupIntent +from stripe.api_resources.source import Source from stripe.util import merge_dicts from stripe.stripe_object import StripeObject +from api_resources.payment_method import PaymentMethod + class ErrorObject(StripeObject): + charge: Optional[str] + code: int + decline_code: Optional[str] + doc_url: Optional[str] + message: Optional[str] + param: Optional[str] + payment_intent: Optional[PaymentIntent] + payment_method: Optional[PaymentMethod] + setup_intent: Optional[SetupIntent] + source: Optional[Source] + type: str + def refresh_from( self, values, From aa507bd1b1ed31c5cc264dadb447e93a8e401d5a Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Tue, 31 Oct 2023 11:40:55 -0700 Subject: [PATCH 2/4] Consistent import --- stripe/api_resources/error_object.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stripe/api_resources/error_object.py b/stripe/api_resources/error_object.py index d1bfe167b..2cfae7caf 100644 --- a/stripe/api_resources/error_object.py +++ b/stripe/api_resources/error_object.py @@ -2,11 +2,10 @@ from stripe.api_resources.payment_intent import PaymentIntent from stripe.api_resources.setup_intent import SetupIntent from stripe.api_resources.source import Source +from stripe.api_resources.payment_method import PaymentMethod from stripe.util import merge_dicts from stripe.stripe_object import StripeObject -from api_resources.payment_method import PaymentMethod - class ErrorObject(StripeObject): charge: Optional[str] From 66e986cc66c1a888ce221538c3ce3dbd990776f1 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:06:03 -0700 Subject: [PATCH 3/4] Update error_object.py --- stripe/api_resources/error_object.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/stripe/api_resources/error_object.py b/stripe/api_resources/error_object.py index 2cfae7caf..90ca968ed 100644 --- a/stripe/api_resources/error_object.py +++ b/stripe/api_resources/error_object.py @@ -1,11 +1,13 @@ from typing import Optional -from stripe.api_resources.payment_intent import PaymentIntent -from stripe.api_resources.setup_intent import SetupIntent -from stripe.api_resources.source import Source -from stripe.api_resources.payment_method import PaymentMethod +from typing_extensions import TYPE_CHECKING from stripe.util import merge_dicts from stripe.stripe_object import StripeObject +if TYPE_CHECKING: + from stripe.api_resources.payment_intent import PaymentIntent + from stripe.api_resources.setup_intent import SetupIntent + from stripe.api_resources.source import Source + from stripe.api_resources.payment_method import PaymentMethod class ErrorObject(StripeObject): charge: Optional[str] @@ -14,10 +16,10 @@ class ErrorObject(StripeObject): doc_url: Optional[str] message: Optional[str] param: Optional[str] - payment_intent: Optional[PaymentIntent] - payment_method: Optional[PaymentMethod] - setup_intent: Optional[SetupIntent] - source: Optional[Source] + payment_intent: Optional["PaymentIntent"] + payment_method: Optional["PaymentMethod"] + setup_intent: Optional["SetupIntent"] + source: Optional["Source"] type: str def refresh_from( From 98aa22e8e60ad19a441b2ff2b459a2377a2039d5 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:08:48 -0700 Subject: [PATCH 4/4] Update stripe/api_resources/error_object.py --- stripe/api_resources/error_object.py | 1 + 1 file changed, 1 insertion(+) diff --git a/stripe/api_resources/error_object.py b/stripe/api_resources/error_object.py index 90ca968ed..6d0c62a4f 100644 --- a/stripe/api_resources/error_object.py +++ b/stripe/api_resources/error_object.py @@ -9,6 +9,7 @@ from stripe.api_resources.source import Source from stripe.api_resources.payment_method import PaymentMethod + class ErrorObject(StripeObject): charge: Optional[str] code: int