Skip to content

Commit

Permalink
Add support for Django 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hugorodgerbrown authored Nov 15, 2023
1 parent d816968 commit 6db81f0
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 132 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
branch = True
omit = tests/*
48 changes: 0 additions & 48 deletions .flake8

This file was deleted.

50 changes: 45 additions & 5 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v4
Expand All @@ -31,20 +31,60 @@ jobs:
run: |
pip install tox
tox
checks:
name: Run Django checks
runs-on: ubuntu-latest
strategy:
matrix:
toxenv: ["django-checks"]
env:
TOXENV: ${{ matrix.toxenv }}

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python (3.11)
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install and run tox
run: |
pip install tox
tox
test:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8", "3.10", "3.11"]
django: [32,41,main]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
# build LTS version, next version, HEAD
django: ["32", "42", "50", "main"]
exclude:
- python: "3.8"
django: "50"
- python: "3.8"
django: "main"
- python: "3.9"
django: "50"
- python: "3.9"
django: "main"
- python: "3.10"
django: "main"
- python: "3.11"
django: "32"
- python: "3.12"
django: "32"

env:
TOXENV: py${{ matrix.python }}-django${{ matrix.django }}
TOXENV: django${{ matrix.django }}-py${{ matrix.python }}

steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
Expand Down
8 changes: 0 additions & 8 deletions .isort.cfg

This file was deleted.

33 changes: 7 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,26 @@
repos:
# python import sorting - will amend files
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort

# python code formatting - will amend files
- repo: https://github.com/ambv/black
rev: 22.10.0
rev: 23.10.1
hooks:
- id: black

- repo: https://github.com/asottile/pyupgrade
rev: v3.2.1
hooks:
- id: pyupgrade

# Flake8 includes pyflakes, pycodestyle, mccabe, pydocstyle, bandit
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: "v0.1.5"
hooks:
- id: flake8
additional_dependencies:
- flake8-bandit
- flake8-blind-except
- flake8-docstrings
- flake8-logging-format
- flake8-print
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

# python static type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.990
rev: v1.7.0
hooks:
- id: mypy
additional_dependencies:
- types-geoip2
args:
- --disallow-untyped-defs
- --disallow-incomplete-defs
- --check-untyped-defs
- --no-implicit-optional
- --ignore-missing-imports
- --follow-imports=silent
exclude: ^tests
66 changes: 66 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
line-length = 88
ignore = [
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"D105", # Missing docstring in magic method
"D106", # Missing docstring in public nested class
"D107", # Missing docstring in __init__
"D203", # 1 blank line required before class docstring
"D212", # Multi-line docstring summary should start at the first line
"D213", # Multi-line docstring summary should start at the second line
"D404", # First word of the docstring should not be "This"
"D405", # Section name should be properly capitalized
"D406", # Section name should end with a newline
"D407", # Missing dashed underline after section
"D410", # Missing blank line after section
"D411", # Missing blank line before section
"D412", # No blank lines allowed between a section header and its content
"D416", # Section name should end with a colon
"D417",
"D417", # Missing argument description in the docstring
]
select = [
"A", # flake8 builtins
"C9", # mcabe
"D", # pydocstyle
"E", # pycodestyle (errors)
"F", # Pyflakes
"I", # isort
"S", # flake8-bandit
"T2", # flake8-print
"W", # pycodestype (warnings)
]

[isort]
combine-as-imports = true

[mccabe]
max-complexity = 8

[per-file-ignores]
"*tests/*" = [
"D205", # 1 blank line required between summary line and description
"D400", # First line should end with a period
"D401", # First line should be in imperative mood
"D415", # First line should end with a period, question mark, or exclamation point
"E501", # Line too long
"E731", # Do not assign a lambda expression, use a def
"S101", # Use of assert detected
"S105", # Possible hardcoded password
"S106", # Possible hardcoded password
"S113", # Probable use of requests call with timeout set to {value}
]
"*/migrations/*" = [
"E501", # Line too long
]
"*/settings.py" = [
"F403", # from {name} import * used; unable to detect undefined names
"F405", # {name} may be undefined, or defined from star imports:
]
"*/settings/*" = [
"F403", # from {name} import * used; unable to detect undefined names
"F405", # {name} may be undefined, or defined from star imports:
]
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All changes to this project will be documented in this file.

## 0.6.0 - 2023-11-11

Add support for Django 5.0, Python 3.12

## 0.5.0 - 2022-12-13

Upgrade our dependency on Stripe from vs 2.x to 5.x
Expand Down
2 changes: 1 addition & 1 deletion django_stripe/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@


class AppConfig(DjangoAppConfig):

name = "django_stripe"
verbose_name = "Stripe"
default_auto_field = "django.db.models.AutoField"

def ready(self) -> None:
from . import settings
Expand Down
1 change: 0 additions & 1 deletion django_stripe/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = []
Expand Down
2 changes: 1 addition & 1 deletion django_stripe/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mode(models.TextChoices):
def from_stripe_livemode(cls, livemode: bool) -> StripeModel.Mode:
return cls.LIVE if livemode else cls.TEST # type: ignore

id = models.BigAutoField(primary_key=True)
id = models.BigAutoField(primary_key=True) # noqa: A003
stripe_id = StripeIdField()

mode = models.CharField(max_length=20, choices=Mode.choices)
Expand Down
20 changes: 6 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-stripe-lite"
version = "0.5.0"
version = "0.6.0"
description = "A library to aid Django integration with Stripe."
license = "MIT"
authors = ["YunoJuno <[email protected]>"]
Expand All @@ -15,44 +15,36 @@ classifiers = [
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"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",
]
packages = [{ include = "django_stripe" }]

[tool.poetry.dependencies]
python = "^3.8"
django = "^3.2 || ^4.0"
django = "^3.2 || ^4.0 | ^5.0"
stripe = "^5.0.0"

[tool.poetry.dev-dependencies]
black = "*"
coverage = "*"
dephell = "*"
flake8 = "*"
flake8-bandit = "*"
flake8-blind-except = "*"
flake8-docstrings = "*"
flake8-logging-format = "*"
flake8-print = "*"
freezegun = "*"
isort = "*"
mypy = "*"
pre-commit = "*"
pytest = "*"
pytest-cov = "*"
pytest-django = "*"
ruff = "*"
tox = "*"

[tool.dephell.main]
from = {format = "poetry", path = "pyproject.toml"}
to = {format = "setuppy", path = "setup.py"}

[build-system]
requires = ["poetry>=1.0.5"]
build-backend = "poetry.masonry.api"
8 changes: 5 additions & 3 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from os import getenv

#############################################
# Relevant django-stripe-lite test settings #
#############################################
Expand All @@ -16,7 +14,10 @@
SECRET_KEY = "TOP_SECRET"

DATABASES = {
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "test.db",}
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "test.db",
}
}

INSTALLED_APPS = (
Expand Down Expand Up @@ -49,6 +50,7 @@
"context_processors": {
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"django.template.context_processors.request",
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_webhook_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import time
from unittest import mock

import stripe
import pytest
import stripe

from django_stripe import settings, webhooks
from django_stripe.models import WebhookEvent
Expand Down
Loading

0 comments on commit 6db81f0

Please sign in to comment.