Skip to content

Commit 280789c

Browse files
vinitkumarampcode-comfsbraun
authored
Add Django 6.0 support to CI (#72)
* Add Django 6.0 support to CI matrix - Add dj60_cms50.txt requirements file for Django 6.0 and CMS 5.0 - Update GitHub Actions workflow to include the new requirements file in test matrix Amp-Thread-ID: https://ampcode.com/threads/T-2bc149c2-fa90-4edd-9d33-5bcc61e7e0fe Co-authored-by: Amp <[email protected]> * Update CI to use uv for faster package installation - Install uv in CI - Use uv venv and uv pip install instead of pip - Update Python matrix to include 3.13 and 3.14 - Update classifiers for Python 3.13, 3.14 and Django 6.0, CMS 6.0 - Change requires-python to >=3.10 Amp-Thread-ID: https://ampcode.com/threads/T-2bc149c2-fa90-4edd-9d33-5bcc61e7e0fe Co-authored-by: Amp <[email protected]> * Upgrade Python syntax to 3.10+ using pyupgrade - Ran pyupgrade --py310-plus on all Python files - Updated syntax for better compatibility with Python 3.10+ Amp-Thread-ID: https://ampcode.com/threads/T-2bc149c2-fa90-4edd-9d33-5bcc61e7e0fe Co-authored-by: Amp <[email protected]> * Fix linting errors with ruff - Removed unused imports: typing.Optional and typing.Union - All ruff checks now pass Amp-Thread-ID: https://ampcode.com/threads/T-2bc149c2-fa90-4edd-9d33-5bcc61e7e0fe Co-authored-by: Amp <[email protected]> * remove uv.lock and update test matrix * fix: requirements * Add djangocms-versioning dependency with version constraint for Python 3.11 compatibility Amp-Thread-ID: https://ampcode.com/threads/T-35fcfaef-4b84-4332-8c74-0609382f872c Co-authored-by: Amp <[email protected]> * fix: test matrix * Fix: typo --------- Co-authored-by: Amp <[email protected]> Co-authored-by: Fabian Braun <[email protected]>
1 parent 6b3b2d6 commit 280789c

File tree

9 files changed

+55
-20
lines changed

9 files changed

+55
-20
lines changed

.github/workflows/test.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,61 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
python-version: [ "3.10", "3.11", "3.12"]
11+
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14"]
1212
requirements-file: [
1313
dj42_cms41.txt,
1414
dj42_cms50.txt,
1515
dj50_cms50.txt,
1616
dj51_cms50.txt,
17-
dj52_cms50.txt
17+
dj52_cms50.txt,
18+
dj60_cms50.txt,
1819
]
1920
os: [
2021
ubuntu-latest,
2122
]
23+
exclude:
24+
- python-version: "3.14"
25+
requirements-file: dj42_cms41.txt
26+
os: ubuntu-latest
27+
- python-version: "3.14"
28+
requirements-file: dj42_cms50.txt
29+
os: ubuntu-latest
30+
- python-version: "3.14"
31+
requirements-file: dj51_cms50.txt
32+
os: ubuntu-latest
33+
- python-version: "3.14"
34+
requirements-file: dj50_cms50.txt
35+
os: ubuntu-latest
36+
- python-version: "3.10"
37+
requirements-file: dj60_cms50.txt
38+
os: ubuntu-latest
39+
- python-version: "3.11"
40+
requirements-file: dj60_cms50.txt
41+
os: ubuntu-latest
2242
steps:
2343
- uses: actions/checkout@v5
2444
- name: Set up Python ${{ matrix.python-version }}
2545
uses: actions/setup-python@v6
2646
with:
2747
python-version: ${{ matrix.python-version }}
48+
- name: Install uv
49+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
2850
- name: Install system deps (cairo stack)
2951
run: |
3052
sudo apt-get update
3153
sudo apt-get install -y \
3254
build-essential libcairo2-dev pkg-config python3-dev
3355
- name: Install dependencies
3456
run: |
35-
python -m pip install --upgrade pip
36-
pip install -r tests/requirements/${{ matrix.requirements-file }}
37-
pip install .
57+
uv venv
58+
source .venv/bin/activate
59+
uv pip install -r tests/requirements/${{ matrix.requirements-file }}
60+
uv pip install .
3861
3962
- name: Run coverage
40-
run: coverage run -m pytest
63+
run: |
64+
source .venv/bin/activate
65+
coverage run -m pytest
4166
4267
- name: Upload Coverage to Codecov
4368
uses: codecov/[email protected]

djangocms_rest/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Callable
1+
from collections.abc import Callable
22

33
from django.contrib.sites.shortcuts import get_current_site
44
from django.contrib.sites.models import Site

djangocms_rest/plugin_rendering.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
2-
from typing import Any, Iterable, Optional, TypeVar
2+
from typing import Any, TypeVar
3+
from collections.abc import Iterable
34

45
from django.contrib.sites.shortcuts import get_current_site
56
from django.core.exceptions import ValidationError
@@ -50,8 +51,8 @@ def get_auto_model_serializer(model_class: type[ModelType]) -> type:
5051

5152

5253
def serialize_cms_plugin(
53-
instance: Optional[Any], context: dict[str, Any]
54-
) -> Optional[dict[str, Any]]:
54+
instance: Any | None, context: dict[str, Any]
55+
) -> dict[str, Any] | None:
5556
if not instance or not hasattr(instance, "get_plugin_instance"):
5657
return None
5758
plugin_instance, plugin = instance.get_plugin_instance()

djangocms_rest/serializers/plugins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Optional
1+
from typing import Any
22

33
from django.apps import apps
44
from django.db.models import Field, Model
@@ -17,7 +17,7 @@ def serialize_fk(
1717
request: HttpRequest,
1818
related_model: type[CMSPlugin],
1919
pk: Any,
20-
obj: Optional[Model] = None,
20+
obj: Model | None = None,
2121
) -> dict[str, Any]:
2222
"""
2323
Serializes a foreign key reference to a related model as a URL or identifier.
@@ -157,7 +157,7 @@ class PluginDefinitionSerializer(serializers.Serializer):
157157
properties = serializers.DictField(help_text="Property definitions")
158158

159159
@staticmethod
160-
def get_field_format(field: Field) -> Optional[str]:
160+
def get_field_format(field: Field) -> str | None:
161161
"""
162162
Get the format for specific field types.
163163

djangocms_rest/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
from typing import Any, Callable, ParamSpec, TypeVar
3+
from typing import Any, ParamSpec, TypeVar
4+
from collections.abc import Callable
45
from django.contrib.sites.shortcuts import get_current_site
56
from django.urls import reverse
67
from django.utils.functional import lazy

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ maintainers = [
1414
]
1515
license = "BSD-3-Clause"
1616
readme = "README.md"
17-
requires-python = ">=3.9"
17+
requires-python = ">=3.10"
1818
dependencies = [
1919
"django-cms>=5.0.0a1",
2020
"djangorestframework",
2121
"djangocms-link>=5.0.0",
2222
"djangocms-text>=0.8.0",
23+
"djangocms-versioning>=2.1.0,<2.4.0",
2324
"pytest-cov>=6.0.0",
2425
"pytest-django>=4.10.0",
2526
]
@@ -31,6 +32,7 @@ classifiers = [
3132
"Framework :: Django :: 5.0",
3233
"Framework :: Django :: 5.1",
3334
"Framework :: Django :: 5.2",
35+
"Framework :: Django :: 6.0",
3436
"Framework :: Django CMS",
3537
"Framework :: Django CMS :: 4.0",
3638
"Framework :: Django CMS :: 4.1",
@@ -42,6 +44,8 @@ classifiers = [
4244
"Programming Language :: Python :: 3.10",
4345
"Programming Language :: Python :: 3.11",
4446
"Programming Language :: Python :: 3.12",
47+
"Programming Language :: Python :: 3.13",
48+
"Programming Language :: Python :: 3.14",
4549
"Topic :: Internet :: WWW/HTTP",
4650
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
4751
"Topic :: Software Development",
@@ -73,4 +77,4 @@ where = ["."]
7377
include = ["djangocms_rest*"]
7478

7579
[tool.ruff]
76-
line-length = 119
80+
line-length = 119

tests/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Union
1+
from typing import Optional
22

33
from cms.api import create_page
44
from cms.models import Page
@@ -16,7 +16,7 @@ class BaseCMSRestTestCase(RESTTestCase):
1616
@classmethod
1717
def _create_pages(
1818
cls,
19-
page_list: Union[int, list[Union[int, tuple[int, int]]]],
19+
page_list: int | list[int | tuple[int, int]],
2020
parent: Optional["Page"] = None,
2121
is_first: bool = True,
2222
):

tests/requirements/dj60_cms50.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-r base.txt
2+
3+
Django>=6.0a1,<6.1
4+
django-cms>=5.0.0a1,<5.1

tests/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from typing import Any, Union
1+
from typing import Any
22
from unittest import TestCase
33

44

55
def assert_field_types(
66
test_case: TestCase,
77
obj: dict[str, Any],
88
field: str,
9-
expected_type: Union[type, tuple[type, ...], list, dict],
9+
expected_type: type | tuple[type, ...] | list | dict,
1010
obj_type: str = "object",
1111
):
1212
"""

0 commit comments

Comments
 (0)