Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix mypy errors for payment
IKarbowiakf85f57cd4706
diff --git a/saleor/payment/gateways/braintree/__init__.py b/saleor/payment/gateways/braintree/__init__.pyindex c3613624b9..d7b054278b 100644--- a/saleor/payment/gateways/braintree/__init__.py+++ b/saleor/payment/gateways/braintree/__init__.py@@ -27,7 +27,7 @@ ERROR_CODES_WHITELIST = {def get_billing_data(payment_information: PaymentData) -> Dict:- billing = {}+ billing: Dict[str, str] = {}if payment_information.billing:billing_info = payment_information.billingbilling = {@@ -69,7 +69,7 @@ def get_error_for_client(errors: List) -> str:def extract_gateway_response(braintree_result) -> Dict:"""Extract data from Braintree response that will be stored locally."""- errors = []+ errors: List[Optional[Dict[str, str]]] = []if not braintree_result.is_success:errors = [{"code": error.code, "message": error.message}diff --git a/saleor/payment/gateways/braintree/plugin.py b/saleor/payment/gateways/braintree/plugin.pyindex 3393b73aec..fe407f0dd8 100644--- a/saleor/payment/gateways/braintree/plugin.py+++ b/saleor/payment/gateways/braintree/plugin.py@@ -19,7 +19,9 @@ from . import (GATEWAY_NAME = "Braintree"if TYPE_CHECKING:+ # flake8: noqafrom . import GatewayResponse, PaymentData, TokenConfig+ from ...interface import CustomerSourcedef require_active_plugin(fn):diff --git a/saleor/payment/gateways/stripe/__init__.py b/saleor/payment/gateways/stripe/__init__.pyindex 19c53683ca..2ae597404a 100644--- a/saleor/payment/gateways/stripe/__init__.py+++ b/saleor/payment/gateways/stripe/__init__.py@@ -186,8 +186,8 @@ def _get_client(**connection_params):def _error_response(- kind: TransactionKind,- exc: Exception,+ kind: str, # use TransactionKind class+ exc: stripe.error.StripeError,payment_info: PaymentData,action_required: bool = False,) -> GatewayResponse:@@ -206,7 +206,7 @@ def _error_response(def _success_response(intent: stripe.PaymentIntent,- kind: TransactionKind,+ kind: str, # use TransactionKind classsuccess: bool = True,amount=None,currency=None,diff --git a/saleor/payment/gateways/stripe/plugin.py b/saleor/payment/gateways/stripe/plugin.pyindex c70b6e51c4..ef201eb01e 100644--- a/saleor/payment/gateways/stripe/plugin.py+++ b/saleor/payment/gateways/stripe/plugin.py@@ -18,7 +18,9 @@ from . import (GATEWAY_NAME = "Stripe"if TYPE_CHECKING:+ # flake8: noqafrom . import GatewayResponse, PaymentData+ from ...interface import CustomerSourcedef require_active_plugin(fn):diff --git a/saleor/payment/gateways/stripe/utils.py b/saleor/payment/gateways/stripe/utils.pyindex 729fae8109..e910452eba 100644--- a/saleor/payment/gateways/stripe/utils.py+++ b/saleor/payment/gateways/stripe/utils.py@@ -77,10 +77,10 @@ def get_currency_from_stripe(currency):def get_payment_billing_fullname(payment_information: PaymentData) -> str:# Get billing name from payment- return "%s %s" % (- payment_information.billing.last_name,- payment_information.billing.first_name,- )+ payment_billing = payment_information.billing+ if not payment_billing:+ return ""+ return "%s %s" % (payment_billing.last_name, payment_billing.first_name,)def shipping_to_stripe_dict(shipping: AddressData) -> Dict: