From f1f9c84634dc86bd01f24ceae74bfc4c625527e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Fri, 24 Oct 2025 17:55:55 +0300 Subject: [PATCH 1/3] Tighhten the return type in braintree.PaymentMethod.find() The possible return types are listed here: https://developer.paypal.com/braintree/docs/reference/response/payment-method/python/ Annoyingly, these classes don't inherit from PaymentMethod, so need to be listed out. --- stubs/braintree/braintree/payment_method.pyi | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/stubs/braintree/braintree/payment_method.pyi b/stubs/braintree/braintree/payment_method.pyi index 9d87458d2c30..496ef88acd8a 100644 --- a/stubs/braintree/braintree/payment_method.pyi +++ b/stubs/braintree/braintree/payment_method.pyi @@ -1,14 +1,22 @@ from _typeshed import Incomplete - +from braintree.android_pay_card import AndroidPayCard +from braintree.apple_pay_card import ApplePayCard +from braintree.credit_card import CreditCard from braintree.error_result import ErrorResult +from braintree.paypal_account import PayPalAccount from braintree.resource import Resource from braintree.successful_result import SuccessfulResult +from braintree.us_bank_account import UsBankAccount +from braintree.venmo_account import VenmoAccount +from braintree.visa_checkout_card import VisaCheckoutCard class PaymentMethod(Resource): @staticmethod def create(params: dict[str, Incomplete] | None = None) -> SuccessfulResult | ErrorResult: ... @staticmethod - def find(payment_method_token: str) -> Resource: ... + def find( + payment_method_token: str, + ) -> AndroidPayCard | ApplePayCard | CreditCard | PayPalAccount | UsBankAccount | VenmoAccount | VisaCheckoutCard: ... @staticmethod def update(payment_method_token: str, params) -> SuccessfulResult | ErrorResult: ... @staticmethod From 0235d964ac9137044913a4d54c1cb49d339b64a5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Oct 2025 14:58:52 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/braintree/braintree/payment_method.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/braintree/braintree/payment_method.pyi b/stubs/braintree/braintree/payment_method.pyi index 496ef88acd8a..70169c7db299 100644 --- a/stubs/braintree/braintree/payment_method.pyi +++ b/stubs/braintree/braintree/payment_method.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete + from braintree.android_pay_card import AndroidPayCard from braintree.apple_pay_card import ApplePayCard from braintree.credit_card import CreditCard From b594aee2c5df8841e7b9f939157368637a1407e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Sat, 25 Oct 2025 17:30:38 +0300 Subject: [PATCH 3/3] Add missing return types and annotate PaymentMethodGateway.find() The Braintree docs don't list the complete list of payment types the library can return, the complete list can be found in braintree.payment_method_parser --- stubs/braintree/braintree/payment_method.pyi | 22 ++++++++++++- .../braintree/payment_method_gateway.pyi | 32 +++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/stubs/braintree/braintree/payment_method.pyi b/stubs/braintree/braintree/payment_method.pyi index 70169c7db299..41ac52cb6807 100644 --- a/stubs/braintree/braintree/payment_method.pyi +++ b/stubs/braintree/braintree/payment_method.pyi @@ -1,12 +1,18 @@ from _typeshed import Incomplete +from braintree.amex_express_checkout_card import AmexExpressCheckoutCard from braintree.android_pay_card import AndroidPayCard from braintree.apple_pay_card import ApplePayCard from braintree.credit_card import CreditCard from braintree.error_result import ErrorResult +from braintree.europe_bank_account import EuropeBankAccount +from braintree.masterpass_card import MasterpassCard from braintree.paypal_account import PayPalAccount from braintree.resource import Resource +from braintree.samsung_pay_card import SamsungPayCard +from braintree.sepa_direct_debit_account import SepaDirectDebitAccount from braintree.successful_result import SuccessfulResult +from braintree.unknown_payment_method import UnknownPaymentMethod from braintree.us_bank_account import UsBankAccount from braintree.venmo_account import VenmoAccount from braintree.visa_checkout_card import VisaCheckoutCard @@ -17,7 +23,21 @@ class PaymentMethod(Resource): @staticmethod def find( payment_method_token: str, - ) -> AndroidPayCard | ApplePayCard | CreditCard | PayPalAccount | UsBankAccount | VenmoAccount | VisaCheckoutCard: ... + ) -> ( + AndroidPayCard + | ApplePayCard + | EuropeBankAccount + | CreditCard + | PayPalAccount + | UsBankAccount + | VenmoAccount + | VisaCheckoutCard + | AmexExpressCheckoutCard + | SepaDirectDebitAccount + | MasterpassCard + | SamsungPayCard + | UnknownPaymentMethod + ): ... @staticmethod def update(payment_method_token: str, params) -> SuccessfulResult | ErrorResult: ... @staticmethod diff --git a/stubs/braintree/braintree/payment_method_gateway.pyi b/stubs/braintree/braintree/payment_method_gateway.pyi index 73393a851e7c..16054b4413d5 100644 --- a/stubs/braintree/braintree/payment_method_gateway.pyi +++ b/stubs/braintree/braintree/payment_method_gateway.pyi @@ -1,15 +1,43 @@ from _typeshed import Incomplete +from braintree.amex_express_checkout_card import AmexExpressCheckoutCard +from braintree.android_pay_card import AndroidPayCard +from braintree.apple_pay_card import ApplePayCard +from braintree.credit_card import CreditCard from braintree.error_result import ErrorResult -from braintree.resource import Resource +from braintree.europe_bank_account import EuropeBankAccount +from braintree.masterpass_card import MasterpassCard +from braintree.paypal_account import PayPalAccount +from braintree.samsung_pay_card import SamsungPayCard +from braintree.sepa_direct_debit_account import SepaDirectDebitAccount from braintree.successful_result import SuccessfulResult +from braintree.unknown_payment_method import UnknownPaymentMethod +from braintree.us_bank_account import UsBankAccount +from braintree.venmo_account import VenmoAccount +from braintree.visa_checkout_card import VisaCheckoutCard class PaymentMethodGateway: gateway: Incomplete config: Incomplete def __init__(self, gateway) -> None: ... def create(self, params: dict[str, Incomplete] | None = None) -> SuccessfulResult | ErrorResult: ... - def find(self, payment_method_token: str) -> Resource: ... + def find( + self, payment_method_token: str + ) -> ( + AndroidPayCard + | ApplePayCard + | EuropeBankAccount + | CreditCard + | PayPalAccount + | UsBankAccount + | VenmoAccount + | VisaCheckoutCard + | AmexExpressCheckoutCard + | SepaDirectDebitAccount + | MasterpassCard + | SamsungPayCard + | UnknownPaymentMethod + ): ... def update(self, payment_method_token: str, params) -> SuccessfulResult | ErrorResult: ... def delete(self, payment_method_token: str, options=None) -> SuccessfulResult: ... options: dict[str, Incomplete]