From 71c022a3a290adb472b4b7bf2524a9ea2856ab01 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 11:04:07 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- payments/paypal/__init__.py | 4 +++- payments/paypal/test_paypal.py | 44 ++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/payments/paypal/__init__.py b/payments/paypal/__init__.py index 5466f95a6..62488e865 100644 --- a/payments/paypal/__init__.py +++ b/payments/paypal/__init__.py @@ -252,7 +252,9 @@ def process_data(self, payment, request): payment.attrs.payer_info = executed_payment["payer"]["payer_info"] if self._capture: payment.captured_amount = payment.total - payment.objects.filter(pk=payment.pk).update(captured_amount=payment.captured_amount) + payment.objects.filter(pk=payment.pk).update( + captured_amount=payment.captured_amount + ) payment.change_status(PaymentStatus.CONFIRMED) else: payment.change_status(PaymentStatus.PREAUTH) diff --git a/payments/paypal/test_paypal.py b/payments/paypal/test_paypal.py index 05a4af8d2..0611071ee 100644 --- a/payments/paypal/test_paypal.py +++ b/payments/paypal/test_paypal.py @@ -51,7 +51,7 @@ def get(self, *args, **kwargs): if args or kwargs: return self.filter(*args, **kwargs).get() payment = Payment() - payment_fields, = self.__payments.values() + (payment_fields,) = self.__payments.values() for payment_field_name, payment_field_value in payment_fields.items(): setattr(payment, payment_field_name, deepcopy(payment_field_value)) return payment @@ -60,14 +60,23 @@ def filter(self, *args, pk=None, **kwargs): if args or kwargs: raise NotImplementedError(f"arguments not supported yet: {args}, {kwargs}") if pk is not None: - return PaymentQuerySet({pk_: payment for pk_, payment in self.__payments.items() if pk_ == pk}) + return PaymentQuerySet( + {pk_: payment for pk_, payment in self.__payments.items() if pk_ == pk} + ) return self def update(self, **kwargs): for payment in self.__payments.values(): for field_name, field_value in kwargs.items(): - if not any(field.name == field_name for field in Payment._meta.get_fields(include_parents=True, include_hidden=True)): - raise NotImplementedError(f"updating unknown field not supported yet: {field_name}") + if not any( + field.name == field_name + for field in Payment._meta.get_fields( + include_parents=True, include_hidden=True + ) + ): + raise NotImplementedError( + f"updating unknown field not supported yet: {field_name}" + ) payment[field_name] = deepcopy(field_value) def delete(self): @@ -129,8 +138,15 @@ def save(self, *args, update_fields=None, **kwargs): if args or kwargs: raise NotImplementedError(f"arguments not supported yet: {args}, {kwargs}") if update_fields is None: - update_fields = {field.name for field in self._meta.get_fields(include_parents=True, include_hidden=True)} - Payment.objects.filter(pk=self.pk).update(**{field: getattr(self, field) for field in update_fields}) + update_fields = { + field.name + for field in self._meta.get_fields( + include_parents=True, include_hidden=True + ) + } + Payment.objects.filter(pk=self.pk).update( + **{field: getattr(self, field) for field in update_fields} + ) def refresh_from_db(self, *args, **kwargs): if args or kwargs: @@ -143,7 +159,21 @@ def refresh_from_db(self, *args, **kwargs): class Meta(Mock): def get_fields(self, include_parents=True, include_hidden=False): fields = [] - for field_name in {"id", "description", "currency", "delivery", "status", "tax", "token", "total", "captured_amount", "variant", "transaction_id", "message", "extra_data"}: + for field_name in { + "id", + "description", + "currency", + "delivery", + "status", + "tax", + "token", + "total", + "captured_amount", + "variant", + "transaction_id", + "message", + "extra_data", + }: field = Mock() field.name = field_name fields.append(field)