Skip to content

Commit

Permalink
Drop support for python 3.8, add support for python 3.12 and django 5…
Browse files Browse the repository at this point in the history
….1 (#973)
  • Loading branch information
jieter authored Nov 6, 2024
1 parent 8c3a58c commit 527c746
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 44 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,26 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
django-version: [4.2, 5.0, 5.1b1, master]
python-version: [3.9, "3.10", 3.11, 3.12] # 3.13 can be supported if lxml supports 3.13
django-version: [4.2, 5.0, 5.1, master]
exclude:
# Django 4.2
- python-version: 3.12
django-version: 4.2
- python-version: 3.13
django-version: 4.2

# Django 5.0
- python-version: 3.8
django-version: 5.0
- python-version: 3.9
django-version: 5.0
- python-version: 3.13
django-version: 5.0

# Django 5.1
- python-version: 3.8
django-version: 5.1b1
- python-version: 3.9
django-version: 5.1b1
django-version: 5.1

# master
- python-version: 3.8
django-version: master
- python-version: 3.9
django-version: master

Expand Down
19 changes: 15 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 24.10.0
hooks:
- id: black
language_version: python3.11

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.19.0
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.1.1
hooks:
- id: flake8

- repo: https://github.com/adamchainz/django-upgrade
rev: "1.22.1"
hooks:
- id: django-upgrade
args: [--target-version, "4.2"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
args: [--py39-plus]

7 changes: 2 additions & 5 deletions django_tables2/columns/jsoncolumn.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import json

from django.db.models import JSONField
from django.utils.html import format_html

from ..utils import AttributeDict
from .base import library
from .linkcolumn import BaseLinkColumn

try:
try:
from django.contrib.postgres.fields import HStoreField
from django.db.models import JSONField # django==3.1 moved JSONField
except ImportError:
from django.contrib.postgres.fields import HStoreField, JSONField
from django.contrib.postgres.fields import HStoreField

POSTGRES_AVAILABLE = True
except ImportError:
Expand Down
6 changes: 3 additions & 3 deletions django_tables2/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from itertools import count
from typing import Any, Dict, Optional
from typing import Any, Optional

from django.core.exceptions import ImproperlyConfigured
from django.views.generic.list import ListView
Expand Down Expand Up @@ -152,7 +152,7 @@ def get_table_kwargs(self):
"""
return {}

def get_context_data(self, **kwargs: Any) -> Dict[str, Any]:
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
"""
Overridden version of `.TemplateResponseMixin` to inject the table into
the template's context.
Expand Down Expand Up @@ -227,7 +227,7 @@ def get_tables_data(self):
"""
return self.tables_data

def get_context_data(self, **kwargs: Any) -> Dict[str, Any]:
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
tables = self.get_tables()

Expand Down
2 changes: 1 addition & 1 deletion example/app/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from .models import Continent, Country


@admin.register(Country)
class CountryAdmin(admin.ModelAdmin):
list_per_page = 20

list_display = ("name", "continent")


admin.site.register(Country, CountryAdmin)
admin.site.register(Continent)
4 changes: 0 additions & 4 deletions example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@
("zh-hans", _("Chinese (Simplified)")),
]

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = join(ROOT, "media")
Expand Down
12 changes: 6 additions & 6 deletions requirements/common.pip
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# xml parsing
lxml==4.9.3
pytz==2023.3.post1
tablib[xls,yaml]==3.5.0
openpyxl==3.1.2
psycopg2-binary==2.9.5
django-filter==23.3
lxml==5.3.0
pytz==2024.2
tablib[xls,yaml]==3.7.0
openpyxl==3.1.5
psycopg2-binary==2.9.10
django-filter==24.3
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"Framework :: Django",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"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",
Expand Down
6 changes: 1 addition & 5 deletions tests/columns/test_jsoncolumn.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
from django.contrib.postgres.fields import HStoreField
from django.db import models
from django.db.models import JSONField
from django.test import SimpleTestCase

import django_tables2 as tables

try:
from django.db.models import JSONField # django==3.1 moved json field
except ImportError:
from django.contrib.postgres.fields import JSONField


class JsonColumnTestCase(SimpleTestCase):
def test_should_be_used_for_json_and_hstore_fields(self):
Expand Down
11 changes: 6 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[tox]
args_are_paths = false
envlist =
py38-{4.2},
py39-{4.2},
py310{4.2,5.0,master},
py311{4.2,5.0,master},
py312{5.0,master},
py310{4.2,5.0,5.1,master},
py311{4.2,5.0,5.1,master},
py312{5.0,5.1,master},
; py313{master},
docs,
flake8,
isort,

[testenv]
basepython =
py38: python3.8
py39: python3.9
py310: python3.10
py311: python3.11
py312: python3.12
py313: python3.13
usedevelop = true
pip_pre = true
setenv =
Expand All @@ -27,6 +27,7 @@ commands =
deps =
4.2: Django==4.2.*
5.0: Django==5.0.*
5.1: Django==5.1.*
master: https://github.com/django/django/archive/master.tar.gz
coverage
-r{toxinidir}/requirements/common.pip
Expand Down

0 comments on commit 527c746

Please sign in to comment.