From 527c746bc0cfb2bdea24ed8caf7ff301d474f950 Mon Sep 17 00:00:00 2001 From: Jan Pieter Waagmeester Date: Wed, 6 Nov 2024 10:18:24 +0100 Subject: [PATCH] Drop support for python 3.8, add support for python 3.12 and django 5.1 (#973) --- .github/workflows/ci.yml | 18 ++++++++---------- .pre-commit-config.yaml | 19 +++++++++++++++---- django_tables2/columns/jsoncolumn.py | 7 ++----- django_tables2/views.py | 6 +++--- example/app/admin.py | 2 +- example/settings.py | 4 ---- requirements/common.pip | 12 ++++++------ setup.py | 2 +- tests/columns/test_jsoncolumn.py | 6 +----- tox.ini | 11 ++++++----- 10 files changed, 43 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d4d14dd..df45c604 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 365f7777..70ab4fa9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] + diff --git a/django_tables2/columns/jsoncolumn.py b/django_tables2/columns/jsoncolumn.py index c1a0f520..e2ae2bc5 100644 --- a/django_tables2/columns/jsoncolumn.py +++ b/django_tables2/columns/jsoncolumn.py @@ -1,5 +1,6 @@ import json +from django.db.models import JSONField from django.utils.html import format_html from ..utils import AttributeDict @@ -7,11 +8,7 @@ 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: diff --git a/django_tables2/views.py b/django_tables2/views.py index 841bf901..b972c0a0 100644 --- a/django_tables2/views.py +++ b/django_tables2/views.py @@ -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 @@ -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. @@ -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() diff --git a/example/app/admin.py b/example/app/admin.py index 4301985d..e54b809a 100644 --- a/example/app/admin.py +++ b/example/app/admin.py @@ -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) diff --git a/example/settings.py b/example/settings.py index 064fa24a..19dc427b 100644 --- a/example/settings.py +++ b/example/settings.py @@ -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") diff --git a/requirements/common.pip b/requirements/common.pip index 25366718..849642da 100644 --- a/requirements/common.pip +++ b/requirements/common.pip @@ -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 diff --git a/setup.py b/setup.py index 66a4fc1e..801c38a5 100755 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/tests/columns/test_jsoncolumn.py b/tests/columns/test_jsoncolumn.py index 6cb8ad51..6a063562 100644 --- a/tests/columns/test_jsoncolumn.py +++ b/tests/columns/test_jsoncolumn.py @@ -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): diff --git a/tox.ini b/tox.ini index fe1ab635..b49a9113 100644 --- a/tox.ini +++ b/tox.ini @@ -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 = @@ -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