From 879526442a01f743ef64fff36a0acf29d6d00c19 Mon Sep 17 00:00:00 2001 From: Mario Hernandez Date: Sat, 14 Dec 2024 18:43:36 -0300 Subject: [PATCH 1/4] Python&Django version upgrades --- pyproject.toml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 772a0b5c4..4e5e94419 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,13 +8,11 @@ authors = [ ] description = "Universal payment handling for Django" readme = "README.rst" -requires-python = ">=3.7" +requires-python = ">=3.9" keywords = ["payments"] license = {text = "BSD"} classifiers = [ "Environment :: Web Environment", - "Framework :: Django :: 3.2", - "Framework :: Django :: 4.1", "Framework :: Django :: 4.2", "Framework :: Django :: 5.0", "Framework :: Django :: 5.1", @@ -22,16 +20,16 @@ classifiers = [ "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Framework :: Django", "Topic :: Software Development :: Libraries :: Application Frameworks", "Topic :: Software Development :: Libraries :: Python Modules", ] dependencies = [ - "Django>=3.2", + "Django>=4.2", "requests>=1.2.0", "django-phonenumber-field[phonenumberslite]>=5.0.0", ] @@ -89,7 +87,7 @@ DJANGO_SETTINGS_MODULE = "test_settings" pythonpath = "." [tool.ruff] -target-version = "py38" +target-version = "py39" [tool.ruff.lint] select = [ From f6c447b314dff3710fefc5a301acd38a91e23e9c Mon Sep 17 00:00:00 2001 From: Mario Hernandez Date: Sat, 14 Dec 2024 18:44:17 -0300 Subject: [PATCH 2/4] Python&Django version upgrades --- tox.ini | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tox.ini b/tox.ini index 4ade0527b..7f478ed1a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,6 @@ [tox] envlist = - py{38,39}-dj32 - py{38,39,310,311}-dj{41,42} + py{39,310,311}-dj{42} py{311,312}-dj{50,51} py{310,311,312}-djmain skip_missing_interpreters = true @@ -13,8 +12,6 @@ ignore_outcome = ignore_errors = djmain: True deps= - dj32: Django>=3.2,<3.3 - dj41: Django>=4.1,<4.2 dj42: Django>=4.2,<5.0 dj50: Django>=5.0,<5.1 dj51: Django>=5.1,<5.2 @@ -33,7 +30,6 @@ commands= [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 3.11: py311 @@ -48,8 +44,6 @@ commands = mypy . [gh-actions:env] DJANGO = - 3.2: dj32 - 4.1: dj41 4.2: dj42 5.0: dj50 5.1: dj51 From 8851a66c5b22683ca2450877f00ea0e80ef93bbc Mon Sep 17 00:00:00 2001 From: Mario Hernandez Date: Sat, 14 Dec 2024 18:44:51 -0300 Subject: [PATCH 3/4] Python&Django version upgrades --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9798f8b85..b5eb896b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,8 +15,8 @@ jobs: fail-fast: false max-parallel: 5 matrix: - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] - django-version: ['3.2', '4.1', '4.2', '5.0', '5.1', 'main'] + python-version: ['3.9', '3.10', '3.11', '3.12'] + django-version: ['4.2', '5.0', '5.1', 'main'] steps: - uses: actions/checkout@v2 From 41eec9285852e34c72d6d1d34a70d03e2f4c26e2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2024 21:46:24 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- payments/mercadopago/test_mercadopago.py | 92 ++++++++++++++---------- payments/models.py | 2 +- 2 files changed, 55 insertions(+), 39 deletions(-) diff --git a/payments/mercadopago/test_mercadopago.py b/payments/mercadopago/test_mercadopago.py index 7a0527ec8..a5111dc61 100644 --- a/payments/mercadopago/test_mercadopago.py +++ b/payments/mercadopago/test_mercadopago.py @@ -202,14 +202,17 @@ def test_approved_payment_notification(rf, mp_provider: MercadoPagoProvider): "status": 200, } - with patch( - "mercadopago.resources.payment.Payment.get", - spec=True, - return_value=payment_info_response, - ) as payment_info, patch( - "payments.mercadopago.redirect", - spec=True, - ) as redirect: + with ( + patch( + "mercadopago.resources.payment.Payment.get", + spec=True, + return_value=payment_info_response, + ) as payment_info, + patch( + "payments.mercadopago.redirect", + spec=True, + ) as redirect, + ): rv = mp_provider.process_data(payment, request) assert payment_info.call_count == 1 @@ -232,13 +235,16 @@ def test_create_preference_failure(mp_provider: MercadoPagoProvider): payment = Payment() - with patch( - "mercadopago.resources.preference.Preference.create", - spec=True, - return_value=preference_info, - ), pytest.raises( - PaymentError, - match="Failed to create MercadoPago preference.", + with ( + patch( + "mercadopago.resources.preference.Preference.create", + spec=True, + return_value=preference_info, + ), + pytest.raises( + PaymentError, + match="Failed to create MercadoPago preference.", + ), ): mp_provider.create_preference(payment) @@ -266,13 +272,16 @@ def test_process_failed_collection(mp_provider: MercadoPagoProvider): } payment = Payment() - with patch( - "mercadopago.resources.payment.Payment.get", - spec=True, - return_value=payment_info, - ), pytest.raises( - PaymentError, - match="MercadoPago sent invalid payment data.", + with ( + patch( + "mercadopago.resources.payment.Payment.get", + spec=True, + return_value=payment_info, + ), + pytest.raises( + PaymentError, + match="MercadoPago sent invalid payment data.", + ), ): mp_provider.process_collection(payment, "12") @@ -331,12 +340,13 @@ def test_get_preference_internal_error(mp_provider: MercadoPagoProvider): payment = Payment() payment.transaction_id = "ABJ122" - with patch( - "mercadopago.resources.preference.Preference.get", - spec=True, - return_value=mocked_response, - ) as get_preference, pytest.raises( - PaymentError, match="Failed to retrieve MercadoPago preference." + with ( + patch( + "mercadopago.resources.preference.Preference.get", + spec=True, + return_value=mocked_response, + ) as get_preference, + pytest.raises(PaymentError, match="Failed to retrieve MercadoPago preference."), ): mp_provider.get_preference(payment) @@ -365,11 +375,14 @@ def test_get_form_for_existing_preference( payment = Payment() payment.transaction_id = "ABJ122" - with patch( - "mercadopago.resources.preference.Preference.get", - spec=True, - return_value=mocked_response, - ) as get_preference, pytest.raises(RedirectNeeded) as exc_info: + with ( + patch( + "mercadopago.resources.preference.Preference.get", + spec=True, + return_value=mocked_response, + ) as get_preference, + pytest.raises(RedirectNeeded) as exc_info, + ): mp_provider.get_form(payment) assert get_preference.call_count == 1 @@ -387,11 +400,14 @@ def test_get_form_for_inexistent_preference(mp_provider: MercadoPagoProvider): } payment = Payment() - with patch( - "mercadopago.resources.preference.Preference.create", - spec=True, - return_value=mocked_response, - ) as get_preference, pytest.raises(RedirectNeeded) as exc_info: + with ( + patch( + "mercadopago.resources.preference.Preference.create", + spec=True, + return_value=mocked_response, + ) as get_preference, + pytest.raises(RedirectNeeded) as exc_info, + ): mp_provider.get_form(payment) assert get_preference.call_count == 1 diff --git a/payments/models.py b/payments/models.py index fe5203aee..303492033 100644 --- a/payments/models.py +++ b/payments/models.py @@ -2,7 +2,7 @@ import json import logging -from typing import Iterable +from collections.abc import Iterable from uuid import uuid4 from django.db import models