Skip to content

Modernize supported Django/Python matrix and drop dead compatibility code - #84

Merged
PetrDlouhy merged 3 commits into
pinax:masterfrom
PetrDlouhy:feature/modernize-support-matrix
Jul 28, 2026
Merged

PetrDlouhy merged 3 commits into
pinax:masterfrom
PetrDlouhy:feature/modernize-support-matrix

Conversation

@PetrDlouhy

Copy link
Copy Markdown
Collaborator

Housekeeping ahead of a 4.4.0 release, following on from #82 and #83.

Where the baseline is set, and why there

Django >= 3.2, Python >= 3.8.

That line is picked by the code rather than the calendar: it is the exact point at which every remaining version-conditional branch in the package becomes dead code. Raising it further would drop more versions while simplifying nothing.

Shim removed Only needed below
default_app_config Django 3.2
is_safe_url fallback for url_has_allowed_host_and_scheme Django 3.0
pkg_resources fallback (added in #82) Python 3.8
MiddlewareMixin → object fallback Django 1.10 — already dead at the old 2.2 floor
runtests.py: MIDDLEWARE_CLASSES, hasattr(django, "setup"), DjangoTestSuiteRunner Django 1.10 / 1.7 / 1.8 — far below the old floor

The account.decorators import is deliberately kept — that is optional-dependency detection for django-user-accounts, not version compatibility.

Removing the Django 1.10 branch also drops runtests.py's distutils import. distutils left the standard library in Python 3.12 and currently only resolves through a setuptools shim, so that was a latent failure waiting on a setuptools release.

python_requires, and why this is 4.4.0 and not 5.0.0

Dropping supported versions is only a minor change if package metadata stops incompatible users from receiving the release — otherwise their pip installs it and it breaks at import.

This package has never declared python_requires; all 15 published releases report requires_python=(none). So when 4.3.0 dropped Python 3.6, nothing prevented a 3.6 user from installing it.

This PR adds python_requires=">=3.8" and raises install_requires to django>=3.2, so users below the baseline resolve to 4.3.x. With that gate in place, this matches the precedent of 4.3.0 dropping Python 3.6 in a minor release.

Two pre-existing bugs fixed along the way

  • The main Django factor never matched. envlist declared djmain environments, but the dep line was master:. No factor named master exists, so those environments installed no explicit Django and silently tested the latest released version instead of main. Renamed to djmain: — the run below confirms it now fetches django/tarball/main.
  • coverage<5 was pinned to a 2019 release; unpinned so it installs on current Pythons.

Also included

  • Test matrix is now Django 3.2, 4.2, 5.2, 6.0 and main across Python 3.8–3.13.
  • Dropping 3.7 lets the workflow return to plain ubuntu-latest — 3.7 was the only entry unavailable on ubuntu-24.04, and Update deprecated GitHub Actions and test invocation so CI can run again #83 had to pin an older runner for it. That pin is now gone.
  • Lint toolchain moved from flake8 3.7.9 / isort 4.3.21 (both 2019) to flake8 7 / isort 5, replacing the removed --recursive flag and the deprecated -sp spelling. isort 5 orders one test module differently; that file is reformatted. flake8 7 reports no new findings.
  • README: refreshed support table, 4.4.0 changelog entry, and the CircleCI badge replaced with the GitHub Actions one, since CI moved some time ago.
  • setup.py classifiers and the long-description support table now match what CI actually proves, instead of claiming Django 2.2/3.0 on Python 3.6–3.8.

Net -23 lines, no functional change to the library.

Verification

Run on a fork before opening: all 7 jobs green, covering 16 tox environments, each confirmed to have actually executed rather than silently skipped:

py38  -> dj32 dj42          py311 -> dj42 dj52
py39  -> dj32 dj42          py312 -> dj42 dj52 dj60 djmain
py310 -> dj32 dj42 dj52     py313 -> dj52 dj60 djmain

Locally I also confirmed the 10 tests pass with system checks clean, and that after removing default_app_config app-config autodiscovery still applies pinax.referrals.apps.AppConfig with its verbose_name and default_auto_field intact.

🤖 Generated with Claude Code

PetrDlouhy and others added 3 commits July 28, 2026 10:44
The supported matrix had drifted far from reality: setup.py still
advertised Django 2.2/3.0 on Python 3.6-3.8, while CI was actually
exercising Django 2.2-5.1 on Python 3.7-3.12.

Set the baseline at Django 3.2 and Python 3.8. That specific line is
not arbitrary - it is the exact point at which every remaining
version-conditional branch in the package becomes dead code (removed in
the following commit). Raising it further would drop more versions
without simplifying anything.

Also add `python_requires`, which this package has never declared.
Without it pip will happily install a release onto an unsupported
Python and fail at import; with it, users below the baseline keep
resolving to 4.3.x. This is what makes dropping versions a minor
release rather than a breaking one.

The test matrix now covers Django 3.2, 4.2, 5.2, 6.0 and main across
Python 3.8-3.13. Dropping 3.7 also lets the workflow go back to plain
`ubuntu-latest`, since 3.7 was the only entry unavailable on
ubuntu-24.04 and needed a pinned older runner.

Two further fixes here: `coverage<5` (from 2019) is unpinned so it can
install on current Pythons, and the `main` Django factor is renamed to
`djmain` so it actually matches the `djmain` envs - as written, the
`master:` dep line matched no factor, so those environments silently
tested the latest released Django instead of main.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
With Django >= 3.2 and Python >= 3.8 guaranteed, every version-
conditional branch in the package is unreachable:

- `default_app_config` is only consulted below Django 3.2; from 3.2 on,
  app-config autodiscovery finds pinax.referrals.apps.AppConfig on its
  own (verified: verbose_name and default_auto_field are still applied).
- The `MiddlewareMixin` fallback to `object` was already dead - the
  mixin has existed since Django 1.10, well below the previous 2.2
  floor - and the fallback would have produced broken middleware anyway.
- `is_safe_url` was the pre-Django-3.0 spelling of
  `url_has_allowed_host_and_scheme`, and was itself removed in Django
  4.0, so the fallback could never fire usefully.
- The `pkg_resources` fallback is only needed below Python 3.8.

runtests.py additionally carried compatibility for Django < 1.10
(MIDDLEWARE_CLASSES), Django < 1.7 (`hasattr(django, "setup")`) and
Django < 1.8 (`django.test.simple.DjangoTestSuiteRunner`) - all far
below even the previous floor. Removing the Django 1.10 check also
drops the `distutils` import, which is no longer in the standard
library from Python 3.12 and only still resolves via a setuptools shim.

The `account.decorators` import is deliberately kept: that is optional-
dependency detection for django-user-accounts, not version compat.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
flake8 3.7.9 and isort 4.3.21 both date from 2019, and the isort
invocation used `--recursive`, a flag removed in isort 5. Move to
flake8 7 and isort 5, and replace the deprecated single-dash `-sp`
with `--settings-path`.

isort 5 orders one test module's imports differently from isort 4
(model_bakery sorts before pinax, which this project's config treats as
third-party); that file is reformatted to match. flake8 7 reports no
new findings.

README: refresh the support table, add the 4.4.0 entry, and replace the
CircleCI badge - CI has been GitHub Actions for some time, so that badge
pointed at a service no longer in use.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@PetrDlouhy
PetrDlouhy merged commit 12e6844 into pinax:master Jul 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant