Skip to content

Commit

Permalink
Merge branch 'main' into drop-dj22
Browse files Browse the repository at this point in the history
  • Loading branch information
WhyNotHugo authored Feb 1, 2024
2 parents 6082843 + 84b52c9 commit 2574ae3
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
django-version: ['3.2', '4.1', '4.2', 'main']

steps:
Expand Down
13 changes: 3 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# vim: set nospell:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
Expand All @@ -13,19 +13,12 @@ repos:
- id: check-added-large-files
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.14
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: docs\/.*
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.5.1"
hooks:
- id: mypy
additional_dependencies:
- types-requests
exclude: testapp
- repo: https://github.com/psf/black
rev: "23.9.1"
rev: "24.1.1"
hooks:
- id: black
6 changes: 3 additions & 3 deletions payments/dotpay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def get_hidden_fields(self, payment):
"currency": payment.currency,
"description": payment.description,
"lang": self.lang,
"ignore_last_payment_channel": "1"
if self.ignore_last_payment_channel
else "0",
"ignore_last_payment_channel": (
"1" if self.ignore_last_payment_channel else "0"
),
"ch_lock": "1" if self.lock else "0",
"URL": payment.get_success_url(),
"URLC": self.get_return_url(payment),
Expand Down
4 changes: 2 additions & 2 deletions payments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def change_status(self, status: PaymentStatus | str, message=""):
"""
from .signals import status_changed

self.status = status
self.status = status # type: ignore[assignment]
self.message = message
self.save(update_fields=["status", "message"])
status_changed.send(sender=type(self), instance=self)
Expand All @@ -83,7 +83,7 @@ def change_fraud_status(self, status: PaymentStatus, message="", commit=True):
status, ", ".join(available_statuses)
)
)
self.fraud_status = status
self.fraud_status = status # type: ignore[assignment]
self.fraud_message = message
if commit:
self.save()
Expand Down
8 changes: 5 additions & 3 deletions payments/sofort/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ def get_form(self, payment, data=None):
"interface_version": "django-payments",
"amount": payment.total,
"currency": payment.currency,
"description": payment.description
if len(payment.description) <= 40
else (payment.description[:37] + "..."),
"description": (
payment.description
if len(payment.description) <= 40
else (payment.description[:37] + "...")
),
"success_url": self.get_return_url(payment),
"abort_url": self.get_return_url(payment),
"customer_protection": "0",
Expand Down
6 changes: 5 additions & 1 deletion payments/stripe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import warnings
from decimal import Decimal
from typing import TYPE_CHECKING

import stripe

Expand All @@ -15,6 +16,9 @@
from .forms import PaymentForm
from .providers import StripeProviderV3

if TYPE_CHECKING:
from django import forms


class StripeProvider(BasicProvider):
"""Provider backend using `Stripe <https://stripe.com/>`_.
Expand All @@ -27,7 +31,7 @@ class StripeProvider(BasicProvider):
:param image: Your logo.
"""

form_class = ModalPaymentForm
form_class: type[forms.Form] = ModalPaymentForm

def __init__(self, public_key, secret_key, image="", name="", **kwargs):
stripe.api_key = secret_key
Expand Down
2 changes: 1 addition & 1 deletion payments/stripe/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def create_session(self, payment):
{
"customer_data": {
"customer_name": "{} {}".format(
payment.billing_first_name, payment.billing_last_nane
payment.billing_first_name, payment.billing_last_name
)
}
}
Expand Down
1 change: 1 addition & 0 deletions payments/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module is responsible for automatic processing of provider callback
data (asynchronous transaction updates).
"""

from __future__ import annotations

from django.db.transaction import atomic
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ braintree = ["braintree>=3.14.0"]
cybersource = ["suds-community>=0.6"]
dev = [
"coverage",
"django-stubs[compatible-mypy]",
"mock",
"pytest",
"pytest-cov",
"pytest-django",
"types-braintree",
"types-dj-database-url",
"types-requests",
"types-stripe",
"types-xmltodict",
]
docs = ["sphinx_rtd_theme"]
mercadopago = ["mercadopago>=2.0.0,<3.0.0"]
Expand All @@ -62,6 +68,13 @@ exclude_lines = [
"if TYPE_CHECKING:",
]

[tool.mypy]
ignore_missing_imports = true
plugins = ["mypy_django_plugin.main"]

[tool.django-stubs]
django_settings_module = "test_settings"

[tool.pytest.ini_options]
addopts =[
"--cov=payments",
Expand Down
1 change: 1 addition & 0 deletions testapp/testapp/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions testapp/testapp/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""

from __future__ import annotations

import os
Expand Down
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ python =
3.9: py39
3.10: py310
3.11: py311
3.12-dev: py312
3.12: py312
3.13-dev: py313

[testenv:mypy]
setenv =
PYTHONPATH = {env:PATH}/testapp
extras = {[testenv]extras}
commands = mypy .

[gh-actions:env]
DJANGO =
Expand Down

0 comments on commit 2574ae3

Please sign in to comment.