Skip to content

Commit

Permalink
💥 Reduce compatibility to Django 4.2
Browse files Browse the repository at this point in the history
Remove compatibility for:
- Django 2.2, 3.0, 3.1, 3.2, 4.0, 4.1
- Python 3.6, 3.7

General changes:
- 💥 Reduce test coverage to Django 4.2
- ⬆️ Upgrade Ubuntu test suite runners 20.04 → 22.04
- 💥 Use Django 4.2 to build documentation
- 💥 Adjust PyPI classifiers and versions
- 🔧 Set pyupgrade to Python 3.8+
    (remove Python 3.6, 3.7)
- ✨ Add django-upgrade to Pre-Commit
- 🔨 Simplify URL path in integration project

Django Deprecations:
- 💥 Replace force_text with force_str
    Deprecated in 2.0, deleted in 3.0.

    https://docs.djangoproject.com/en/stable/releases/2.0/#backwards-incompatible-changes-in-2-0
    https://docs.djangoproject.com/en/stable/releases/3.0/#features-deprecated-in-3-0

- 💥 Remove default_app_config variable
    Deprecated in 3.2, removed in 4.1.

    https://docs.djangoproject.com/en/stable/releases/3.2/#features-deprecated-in-3-2
    https://docs.djangoproject.com/en/stable/releases/4.1/#features-removed-in-4-1

- 💥 Remove USE_L10N
    Deprecated in 4.0, removed in 5.0.

    https://docs.djangoproject.com/en/stable/releases/4.0/#localization
    https://docs.djangoproject.com/en/stable/releases/5.0/#features-removed-in-5-0

PR #303
  • Loading branch information
jambonrose authored Aug 8, 2024
1 parent 2ff2ef4 commit a943e4c
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 104 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/run-project-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
- src/**
- tests/**
- example_extension_project/**
- example_integration_project/**
- example_replacement_project/**

env:
Expand All @@ -22,24 +21,17 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2022]
# Django LTS versions & latest version only
django-version: ["2.2", "3.2", "4.2"]
project: ["extension", "integration", "replacement"]
exclude:
# Django Registration 2 does not support Django above 2.2
- django-version: "3.2"
project: "integration"
- django-version: "4.2"
project: "integration"
os: [ubuntu-22.04, windows-2022]
django-version: ["4.2"]
project: ["extension", "replacement"]

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.12"

- name: Upgrade pip
run: python3 -m pip install -U distlib pip setuptools wheel
Expand Down
54 changes: 3 additions & 51 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,9 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2022]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
django-version: ["2.2", "3.0", "3.1", "3.2", "4.0", "4.1", "4.2"]
exclude:
# Django 2.2
- django-version: "2.2"
python-version: "3.10"
- django-version: "2.2"
python-version: "3.11"
- django-version: "2.2"
python-version: "3.12"
# Django 3.0
- django-version: "3.0"
python-version: "3.10"
- django-version: "3.0"
python-version: "3.11"
- django-version: "3.0"
python-version: "3.12"
# Django 3.1
- django-version: "3.1"
python-version: "3.10"
- django-version: "3.1"
python-version: "3.11"
- django-version: "3.1"
python-version: "3.12"
# Django 3.2
- django-version: "3.2"
python-version: "3.11"
- django-version: "3.2"
python-version: "3.12"
# Django 4.0
- django-version: "4.0"
python-version: "3.6"
- django-version: "4.0"
python-version: "3.7"
- django-version: "4.0"
python-version: "3.11"
- django-version: "4.0"
python-version: "3.12"
# Django 4.1
- django-version: "4.1"
python-version: "3.6"
- django-version: "4.1"
python-version: "3.7"
- django-version: "4.1"
python-version: "3.12"
# Django 4.2
- django-version: "4.2"
python-version: "3.6"
- django-version: "4.2"
python-version: "3.7"
os: [ubuntu-22.04, windows-2022]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
django-version: ["4.2"]

steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ repos:
rev: v3.17.0
hooks:
- id: pyupgrade
args: [--py36-plus]
args: [--py38-plus]
- repo: https://github.com/adamchainz/django-upgrade
rev: "1.20.0"
hooks:
- id: django-upgrade
args: [--target-version, "4.2"]
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
Expand Down
2 changes: 1 addition & 1 deletion doc-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django>=3.2,<3.3
Django>=4.2,<4.3
factory-boy==3.3.0
Faker==26.1.0
Pygments==2.18.0
Expand Down
10 changes: 5 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import sphinx_rtd_theme # noqa: F401
from django import setup as django_setup
from django.conf import settings as django_settings
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.html import strip_tags

sys.path.insert(0, abspath(join("..", "src")))
Expand All @@ -53,9 +53,9 @@ def annotate_field(lines, field, models):

if field.help_text:
# Decode and strip any html out of the field's help text
help_text = strip_tags(force_text(field.help_text))
help_text = strip_tags(force_str(field.help_text))
else:
help_text = force_text(field.verbose_name).capitalize()
help_text = force_str(field.verbose_name).capitalize()
# Add the model field to the end of the docstring as a param
# using the verbose name as the description
lines.append(f":param {field.attname}: {help_text}")
Expand Down Expand Up @@ -102,9 +102,9 @@ def process_docstring(app, what, name, obj, options, lines):
field = form.base_fields[field_name]
if field.help_text:
# Decode and strip any html out of the field's help text
help_text = strip_tags(force_text(field.help_text))
help_text = strip_tags(force_str(field.help_text))
else:
help_text = force_text(field.label).capitalize()
help_text = force_str(field.label).capitalize()
lines.append(f":param {field_name}: {help_text}")
if field.widget.is_hidden:
lines.append(
Expand Down
1 change: 0 additions & 1 deletion example_extension_project/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True

Expand Down
1 change: 0 additions & 1 deletion example_integration_project/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True

Expand Down
6 changes: 2 additions & 4 deletions example_integration_project/config/urls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""Integration project URL Configuration"""

from django.contrib import admin
from django.urls import re_path
from django.urls import path, re_path
from django.views.generic import TemplateView

urlpatterns = [
re_path(r"^admin/", admin.site.urls),
re_path(
r"^$", TemplateView.as_view(template_name="home.html"), name="home"
),
path("", TemplateView.as_view(template_name="home.html"), name="home"),
]
1 change: 0 additions & 1 deletion example_replacement_project/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True

Expand Down
16 changes: 4 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
requires = ["flit_core >=3.4,<4"]
build-backend = "flit_core.buildapi"

[project]
Expand All @@ -10,8 +10,8 @@ authors = [
{ name = "Andrew Pinkham" },
]
readme = "README.rst"
requires-python = ">=3.6"
dependencies = ["django>=2.2"]
requires-python = ">=3.8"
dependencies = ["django>=4.2"]
license = { file = "LICENSE"}
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand All @@ -20,21 +20,13 @@ classifiers = [
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"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",
"Programming Language :: Python :: 3 :: Only",
"Framework :: Django",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.0",
"Framework :: Django :: 3.1",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
]

Expand Down Expand Up @@ -87,5 +79,5 @@ exclude = [

[tool.black]
line-length = 79
target-version = ['py36', 'py37', 'py38', 'py39']
target-version = ['py38']
include = '\.pyi?$'
1 change: 0 additions & 1 deletion src/improved_user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
# pylint: disable=invalid-name
__version__ = "2.1.0"
# https://docs.djangoproject.com/en/stable/ref/applications/#configuring-applications
default_app_config = "improved_user.apps.ImprovedUserConfig"
# pylint: enable=invalid-name
17 changes: 3 additions & 14 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
[tox]
isolated_build = True
envlist =
py311-django42-pkgcheck,
py312-django42-pkgcheck,
py312-docs,
py{36,37,38,39}-django{22,30,31}-unit,
py{36,37,38,39,310}-django32-unit,
py{38,39,310}-django40-unit,
py{38,39,310,311}-django41-unit,
py{38,39,310,311,312}-django42-unit,
py39-django{22,32,42}-{extension,replacement}
py312-django42-{extension,replacement}

[testenv]
changedir =
Expand All @@ -19,8 +15,7 @@ changedir =
skip_install =
pkgcheck: true
extras =
{extension,
replacement,unit}: factory
{extension,replacement,unit}: factory
setenv =
PYTHONDONTWRITEBYTECODE=1
{extension,replacement,unit}: PYTHONWARNINGS=once
Expand All @@ -29,12 +24,6 @@ deps =
docs: -r{toxinidir}/doc-requirements.txt
extension: -r{toxinidir}/example_extension_project/requirements.txt
replacement: -r{toxinidir}/example_replacement_project/requirements.txt
django22: Django>=2.2,<2.3
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2
django32: Django>=3.2,<3.3
django40: Django>=4.0,<4.1
django41: Django>=4.1,<4.2
django42: Django>=4.2,<4.3
commands =
docs: sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
Expand Down

0 comments on commit a943e4c

Please sign in to comment.