From 7ec34a7720719139d37e34c4a1e2fdb1ff0c1d17 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Mon, 14 Aug 2023 11:13:44 +0200 Subject: [PATCH] Replace pyupgrade with ruff --- .pre-commit-config.yaml | 5 ----- payments/sagepay/__init__.py | 2 +- payments/sagepay/test_sagepay.py | 4 ++-- payments/stripe/test_stripe.py | 14 ++++++++------ pyproject.toml | 1 + 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ef4b5ada1..f9a4e0407 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,11 +18,6 @@ repos: - id: ruff args: [--fix, --exit-non-zero-on-fix] exclude: docs\/.* - - repo: https://github.com/asottile/pyupgrade - rev: v3.4.0 - hooks: - - id: pyupgrade - args: [--py38-plus] - repo: https://github.com/pre-commit/mirrors-mypy rev: "v1.3.0" hooks: diff --git a/payments/sagepay/__init__.py b/payments/sagepay/__init__.py index 7dffd04f2..b88943f0e 100644 --- a/payments/sagepay/__init__.py +++ b/payments/sagepay/__init__.py @@ -90,7 +90,7 @@ def get_hidden_fields(self, payment): if payment.billing_country_code == "US": data["BillingState"] = payment.billing_country_area data["DeliveryState"] = payment.billing_country_area - udata = "&".join("%s=%s" % kv for kv in data.items()) + udata = "&".join("{}={}".format(*kv) for kv in data.items()) crypt = self.aes_enc(udata) return { "VPSProtocol": self._version, diff --git a/payments/sagepay/test_sagepay.py b/payments/sagepay/test_sagepay.py index 024ce6e2a..93d8cc44f 100644 --- a/payments/sagepay/test_sagepay.py +++ b/payments/sagepay/test_sagepay.py @@ -41,7 +41,7 @@ def setUp(self): @patch("payments.sagepay.redirect") def test_provider_raises_redirect_needed_on_success(self, mocked_redirect): data = {"Status": "OK"} - data = "&".join("%s=%s" % kv for kv in data.items()) + data = "&".join("{}={}".format(*kv) for kv in data.items()) with patch.object(SagepayProvider, "aes_dec", return_value=data): self.provider.process_data(self.payment, MagicMock()) self.assertEqual(self.payment.status, PaymentStatus.CONFIRMED) @@ -50,7 +50,7 @@ def test_provider_raises_redirect_needed_on_success(self, mocked_redirect): @patch("payments.sagepay.redirect") def test_provider_raises_redirect_needed_on_failure(self, mocked_redirect): data = {"Status": ""} - data = "&".join("%s=%s" % kv for kv in data.items()) + data = "&".join("{}={}".format(*kv) for kv in data.items()) with patch.object(SagepayProvider, "aes_dec", return_value=data): self.provider.process_data(self.payment, MagicMock()) self.assertEqual(self.payment.status, PaymentStatus.REJECTED) diff --git a/payments/stripe/test_stripe.py b/payments/stripe/test_stripe.py index 560b27674..69fff7778 100644 --- a/payments/stripe/test_stripe.py +++ b/payments/stripe/test_stripe.py @@ -91,9 +91,10 @@ def test_form_contains_stripe_script(self): self.assertTrue( '' - % (PUBLIC_KEY, store_name) + 'data-image="" data-key="{}" data-name="{}" ' + 'src="https://checkout.stripe.com/checkout.js">'.format( + PUBLIC_KEY, store_name + ) in str(form) ) @@ -114,9 +115,10 @@ def test_form_contains_stripe_script_without_billing_email(self): self.assertTrue( '' - % (PUBLIC_KEY, store_name) + 'data-image="" data-key="{}" data-name="{}" ' + 'src="https://checkout.stripe.com/checkout.js">'.format( + PUBLIC_KEY, store_name + ) in str(form) ) diff --git a/pyproject.toml b/pyproject.toml index 53d1ea14a..29c3b7c38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,7 @@ select = [ "F", "W", "B", + "UP", "C4", ] target-version = "py38"