Skip to content

Commit 1902d29

Browse files
authored
42 add support for django 60x fix support for django 52x patches (#43)
* Add support for Django 5.2.x series and Django 6.0.x series Close #42 * Use the Pyproject toml settings for black * fix black * Increase python versions to include 3.14 * try adding dependency group conflicts * use dependency groups in ci.yml * switch to using locmen for tests * additional debugging * add shim for legacy mixed_subtype * fix formatting with black * Update CHANGELOG
1 parent 0c5b32a commit 1902d29

14 files changed

Lines changed: 345 additions & 43 deletions

File tree

.github/workflows/black.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ jobs:
88
steps:
99
- uses: actions/checkout@v4
1010
- uses: psf/black@stable
11+
with:
12+
use_pyproject: true

.github/workflows/ci.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,41 @@ jobs:
99
matrix:
1010
include:
1111
# Django 3.2
12-
- django-version: "3.2.25"
12+
- django-version: "32"
1313
python-version: "3.10"
1414
# Django 4.2
15-
- django-version: "4.2.23"
15+
- django-version: "42"
1616
python-version: "3.10"
17-
- django-version: "4.2.23"
17+
- django-version: "42"
1818
python-version: "3.11"
19-
- django-version: "4.2.23"
19+
- django-version: "42"
2020
python-version: "3.12"
2121
# Django 5.2
22-
- django-version: "5.2.3"
22+
- django-version: "52"
2323
python-version: "3.10"
24-
- django-version: "5.2.3"
24+
- django-version: "52"
2525
python-version: "3.11"
26-
- django-version: "5.2.3"
26+
- django-version: "52"
2727
python-version: "3.12"
28-
- django-version: "5.2.3"
28+
- django-version: "52"
2929
python-version: "3.13"
30+
- django-version: "52"
31+
python-version: "3.14"
32+
# Django 6.0
33+
- django-version: "60"
34+
python-version: "3.12"
35+
- django-version: "60"
36+
python-version: "3.13"
37+
- django-version: "60"
38+
python-version: "3.14"
3039
steps:
3140
- uses: actions/checkout@v4
3241
- name: Set up uv
3342
uses: astral-sh/setup-uv@v6
3443
with:
3544
python-version: ${{ matrix.python-version }}
36-
- name: Use specific django version
37-
run: uv add -U django~=${{ matrix.django-version }}
38-
- name: Install dependencies
39-
run: uv sync --all-extras
45+
- name: Install dependencies using specifc django dependency group
46+
run: uv sync --all-extras --group django${{ matrix.django-version }}
4047
- name: Run tests
4148
run: uv run coverage run -m django test --settings=tests.settings --pythonpath=. -v 2
4249
- name: Report coverage to Codecov

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unrelease (tbd)
44

5+
## 0.5.0 (2025-01-28)
6+
- #42 via MR #43 - Add support for Django 6.0, fix support for Django 5.2, add support for Python 3.14
7+
58

69
## 0.4.2 (2025-09-12)
710
- #35 via MR #36 - Add security policy via `SECURITY.md`

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
* Twilio (SemVer) is supported till latest major version - 1 (e.g 9.x.x - 1 = version 8.x.x and higher)
4444
* html2text (CalVer) is supported till current calendar year - 1 (e.g. 2025 - 1 = version 2024.x.x and newer)
4545

46+
## Code Style
47+
48+
### Python Code
49+
50+
To format your code with Black, open a terminal and ensure your virtual environment is activated.
51+
52+
```bash
53+
uv run black .
54+
```
55+
4656
## Running Tests
4757

4858
This will run tests with a SQLite3 in-memory database and coverage:

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ For python, Heralder supports all versions of python that the above versions of
3434

3535
We currently support:
3636

37-
| Django | Python `3.10` | Python `3.11` | Python `3.12` | Python `3.13` |
38-
| --- | --- | --- | --- | --- |
39-
| `3.2.x` | **Y** | - | - | - |
40-
| `4.2.x` | **Y** | **Y** | **Y** | - |
41-
| `5.2.x` | **Y** | **Y** | **Y** | **Y** |
37+
| Django | Python `3.10` | Python `3.11` | Python `3.12` | Python `3.13` | Python `3.14` |
38+
| --- | --- | --- | --- | --- | --- |
39+
| `3.2.x` | **Y** | - | - | - | - |
40+
| `4.2.x` | **Y** | **Y** | **Y** | - | - |
41+
| `5.2.x` | **Y** | **Y** | **Y** | **Y** | **Y** |
42+
| `6.0.x` | - | - | **Y** | **Y** | **Y** |
43+
44+
4245

4346
### Installation
4447

pyproject.toml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ packages = ["src/herald"]
88
[project]
99
name = "django-heralder"
1010
version = "0.4.2"
11-
requires-python = ">=3.10,<3.14"
11+
requires-python = ">=3.10,<3.15"
1212
readme = "README.md"
1313
license = "MIT"
1414
description = "Django library for separating the message content from transmission method."
@@ -17,7 +17,7 @@ authors = [
1717
]
1818

1919
dependencies = [
20-
"django>=3.2,<=5.2",
20+
"django>=3.2,<=6.1",
2121
"jsonpickle>=4.1.1",
2222
]
2323

@@ -35,12 +35,14 @@ classifiers = [
3535
"Framework :: Django :: 3.2",
3636
"Framework :: Django :: 4.2",
3737
"Framework :: Django :: 5.2",
38+
"Framework :: Django :: 6.0",
3839
"Programming Language :: Python",
3940
"Programming Language :: Python :: 3",
4041
"Programming Language :: Python :: 3.10",
4142
"Programming Language :: Python :: 3.11",
4243
"Programming Language :: Python :: 3.12",
4344
"Programming Language :: Python :: 3.13",
45+
"Programming Language :: Python :: 3.14",
4446
"Programming Language :: Python :: 3 :: Only",
4547
"License :: OSI Approved :: MIT License",
4648
]
@@ -55,10 +57,15 @@ html2text = [
5557

5658
[dependency-groups]
5759
dev = [
60+
"black>=26.1.0",
5861
"coveralls>=4.0.1",
5962
"mock>=5.2.0",
6063
"pytz>=2025.2",
6164
]
65+
django32 = [ "django>=3.2a1,<4; python_version>='3.10'" ]
66+
django42 = [ "django>=4.2a1,<5; python_version>='3.10'" ]
67+
django52 = [ "django>=5.2a1,<6; python_version>='3.10'" ]
68+
django60 = [ "django>=6a1,<6.1; python_version>='3.12'" ]
6269

6370
[project.urls]
6471
Homepage = "https://github.com/peterfarrell/django-heralder"
@@ -68,6 +75,15 @@ Changelog = "https://github.com/peterfarrell/django-heralder/blob/main/CHANGELOG
6875

6976
[tool.uv]
7077
package = true
78+
# Conflicts: https://docs.astral.sh/uv/reference/settings/#conflicts
79+
conflicts = [
80+
[
81+
{ group = "django32" },
82+
{ group = "django42" },
83+
{ group = "django52" },
84+
{ group = "django60" },
85+
],
86+
]
7187

7288
[[tool.uv.index]]
7389
name = "testpypi"

setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import sys
22

3-
sys.stderr.write(
4-
"""\
3+
sys.stderr.write("""\
54
===============================
65
Unsupported installation method
76
===============================
87
This project no longer supports installation with `python setup.py install .`.
98
Please use `python -m pip install .` instead.
10-
"""
11-
)
9+
""")
1210
sys.exit(1)

src/herald/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from mimetypes import guess_type
55

66
import jsonpickle
7+
import django
78
from django.conf import settings
89
from django.contrib.sites.models import Site
910
from django.core.files import File
@@ -14,6 +15,10 @@
1415

1516
from herald.utils import get_sent_notification_model
1617

18+
use_legacy_mixed_subtype: bool = False
19+
if django.VERSION < (5, 0):
20+
use_legacy_mixed_subtype: bool = True
21+
1722

1823
class NotificationBase:
1924
"""
@@ -451,7 +456,8 @@ def _send(
451456
# All mimebase attachments must have a Content-ID or Content-Disposition header
452457
# or they will show up as unnamed attachments"
453458
if isinstance(attachment, MIMEBase):
454-
if attachment.get("Content-ID", False):
459+
# `mixed_subtype` was removed from Django 5+
460+
if use_legacy_mixed_subtype and attachment.get("Content-ID", False):
455461
# if you are sending attachment with content id,
456462
# subtype must be 'related'.
457463
mail.mixed_subtype = "related"

src/herald/urls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from .views import TestNotification, TestNotificationList
44

5-
65
urlpatterns = [
76
re_path(r"^$", TestNotificationList.as_view(), name="herald_preview_list"),
87
re_path(

tests/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
4242

43-
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
43+
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
4444

4545
STATIC_URL = "/static/"
4646

0 commit comments

Comments
 (0)