Skip to content

chore: Drop legacy Django 2 / Python 2 compatibility shims - #204

Merged
jezdez merged 4 commits into
masterfrom
chore/drop-legacy-shims
Nov 11, 2026
Merged

jezdez merged 4 commits into
masterfrom
chore/drop-legacy-shims

Conversation

@andruten

@andruten andruten commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This branch now requires Python >= 3.11 and Django >= 4.2 , so all compatibility fallbacks for older versions have been removed, and the CI matrix now covers modern Python and Django versions.

Dead code cleanup

  • revproxy/views.py — Removed the try/except fallback importing urllib.parse via django.utils.six.moves. six was removed from Django in 3.0, so the fallback was the only branch ever executed. It now imports directly from urllib.parse.
  • revproxy/transformer.py: Removed the django.utils.six.string_types shim; use str directly (isinstance(value, str)).
  • revproxy/utils.py: Removed the Python 2 fallback importing from the Cookie module; use http.cookies.SimpleCookie directly. With the Python 2 branch gone, COOKIE_PREFIX was always '', so it was dropped and simplified to SimpleCookie(cookie_string).
  • tests/test_views.py: Removed the django.utils.six.moves fallback; import ParseResult directly from urllib.parse.
  • tests/test_request.py: Removed the sys.version_info >= (3, 0, 0) conditional and its Python 2 urlparse import; import parse_qs unconditionally and drop the now-unused import sys.

Python 3.12/3.13 compatibility

  • tests/test_utils.py: Replaced assertDictContainsSubset (removed from unittest in Python 3.12) with an equivalent dict-items comparison. Caught by running the suite on Python 3.13.

Extended CI matrix

  • tox.ini: The matrix covers py3{11,12}-dj{42,52} and py313-dj52, matching CI. The gh-actions entries cover Python 3.11/3.12/3.13 and Django 4.2/5.2. Django 4.1 (EOL) has been dropped.
  • .github/workflows/test.yml: The matrix is now python-version: ['3.11', '3.12', '3.13'] × django-version: ['4.2', '5.2'], with DJANGO set from the matrix. The py313-dj42 combination is excluded, since Django 4.2 does not officially support Python 3.13. Actions bumped: checkout@v4, setup-python@v5.

Metadata

  • pyproject.toml: Dependency updated to Django>=4.2; classifiers added for Python 3.12, 3.13 and Django 4.2, 5.2.
  • README.rst: Requirement updated to Django ≥ 4.2.
  • CHANGELOG.rst: Entry updated to reflect the new minimums and the CI matrix.

Notes for reviewers

  • No behavioral changes intended beyond test fixes — dead code removal plus CI/matrix configuration.
  • The py312-dj42 combination was not run locally (no local 3.12 interpreter), but matches code paths tested on 3.11/3.13; CI covers it.
  • revproxy/views.py still imports sys (it's used elsewhere in the file).

@andruten
andruten changed the base branch from master to fix/python311-support October 26, 2026 22:10
@andruten andruten changed the title chore: drop legacy shims chore: Drop legacy Django 2 / Python 2 compatibility shims Oct 26, 2026
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (fix/python311-support@a519f50). Learn more about missing BASE report.

Additional details and impacted files
@@                   Coverage Diff                    @@
##             fix/python311-support     #204   +/-   ##
========================================================
  Coverage                         ?   97.45%           
========================================================
  Files                            ?        9           
  Lines                            ?      432           
  Branches                         ?       67           
========================================================
  Hits                             ?      421           
  Misses                           ?        6           
  Partials                         ?        5           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jezdez jezdez mentioned this pull request Oct 27, 2026
10 of 21 tasks
@jezdez
jezdez added this pull request to stack #206 October 27, 2026 18:32
@andruten
andruten requested a review from codingjoe November 4, 2026 11:46
jezdez
jezdez previously approved these changes Nov 5, 2026
Base automatically changed from fix/python311-support to master November 5, 2026 16:47
@andruten
andruten dismissed jezdez’s stale review November 5, 2026 16:47

The merge-base changed after approval.

andruten and others added 4 commits November 5, 2026 17:47
- Remove django.utils.six fallback imports (views, transformer, tests)
- Use http.cookies.SimpleCookie directly and drop py2 COOKIE_PREFIX
- Remove Python version checks in tests (require Python 3.11+)
- Extend tox and GitHub Actions matrix to Python 3.11, 3.12 and 3.13
- Test Django 4.2 and 5.2 (drop 4.1, which is EOL)
- Require Django 4.2 or newer in pyproject.toml
- Exclude py313-dj42 (unsupported combination)
- Replace assertDictContainsSubset, removed in Python 3.12's unittest
No behavior change; removes the class-name coupling that can silently
skip classes in the MRO if a class is renamed/derived.
@jezdez
jezdez force-pushed the chore/drop-legacy-shims branch from 1ed55e8 to 2a42b51 Compare November 5, 2026 16:47

@codingjoe codingjoe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick side note, Django 4.2 is also EoL and even 5.2 is only good until December.

Comment thread tox.ini

deps =
dj41: Django>=4.1.3,<4.2
dj42: Django>=4.2,<5.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can go too, can't it?

@jezdez
jezdez merged commit 3a2a1f0 into master Nov 11, 2026
11 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.

3 participants