Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Modernize Python and Django support: Drop Python 3.9, add Python 3.14 and Django 6.0 #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vinitkumar wants to merge 17 commits into master
base: master
Choose a base branch
Loading
from feature/modernize-python-django-support

Conversation

@vinitkumar
Copy link
Member

@vinitkumar vinitkumar commented Oct 24, 2025
edited by sourcery-ai bot
Loading

This PR modernizes the project's Python and Django version support, following the approach from django-cms PR #8371.

Changes

Python Version Support

  • Removed Python 3.9 support (approaching end-of-life)
  • Added Python 3.14 support
  • Updated requires-python to >= 3.10
  • Added Python classifiers for 3.10, 3.11, 3.12, 3.13, 3.14

Django Version Support

  • Added Django 6.0 support
  • Created tests/requirements/dj60_cms50.txt for Django 6.0 testing
  • Added Django 6.0 classifier to pyproject.toml

Code Modernization

  • Modernized type annotations using PEP 604 syntax:
    • Replaced typing.Union[X, Y] with X | Y
    • Replaced typing.Optional[X] with X | None
  • Removed unused typing imports after modernization
  • Updated files: admin.py, emails.py, conditions.py, helpers.py, cms_toolbars.py, indicators.py, datastructures.py

CI/CD Improvements

  • Updated test matrix in GitHub Actions workflows
  • Added Python 3.14 to test matrix with proper exclusions
  • Added Django 6.0 to test matrix
  • Python 3.14 only runs against Django 6.0 (excluded from older versions)
  • Updated tox.ini to reflect new Python/Django version support

Documentation

  • Updated AGENTS.md with new version requirements
  • Added PEP 604 union syntax guidance for type hints

Testing Strategy

  • Python 3.10-3.14 tested against appropriate Django versions
  • Django 6.0 tested with Python 3.13+
  • Maintained backward compatibility with Django 4.2+

Checklist

  • Code follows project style guidelines (ruff checks pass)
  • Type annotations modernized for Python 3.10+
  • CI/CD workflows updated
  • Documentation updated
  • Atomic commits with clear messages

Closes #XXX (if applicable)

Summary by Sourcery

Modernize the project’s Python and Django support by dropping Python 3.9, requiring Python >=3.10, adding Python 3.14 and Django 6.0 support, updating type hints to PEP 604 syntax, and refreshing CI, tox, and documentation accordingly.

New Features:

  • Add support for Python 3.14
  • Add support for Django 6.0

Enhancements:

  • Drop Python 3.9 support and bump minimum Python requirement to 3.10
  • Modernize type annotations to use PEP 604 union syntax and remove unused typing imports

Build:

  • Expand GitHub Actions test matrix and tox.ini to include Python 3.13, 3.14 and Django 6.0 with appropriate exclusions

Documentation:

  • Update pyproject.toml classifiers and AGENTS.md with new version requirements and PEP 604 guidance

Tests:

  • Add tests/requirements/dj60_cms50.txt for Django 6.0

vinitkumar and others added 4 commits October 25, 2025 03:30
- Update pyproject.toml: requires-python >= 3.10, add classifiers for Python 3.10-3.14 and Django 6.0
- Update tox.ini: remove py39, add py310, py312, py313, py314
- Update GitHub Actions workflows: add Python 3.14 and Django 6.0 test configurations
- Add dj60_cms50.txt requirements file for Django 6.0 testing
- Add exclusions to prevent Python 3.14 from running against older Django versions
Amp-Thread-ID: https://ampcode.com/threads/T-cdf01cfa-6da3-4851-9a9b-0c7a2c181c37
Co-authored-by: Amp <amp@ampcode.com>
- Replace typing.Union[X, Y] with X | Y syntax (PEP 604)
- Replace typing.Optional[X] with X | None syntax
- Remove unnecessary typing imports where Optional/Union were the only imports
- Updated files: admin.py, emails.py, conditions.py, helpers.py, cms_toolbars.py, indicators.py, datastructures.py
Amp-Thread-ID: https://ampcode.com/threads/T-cdf01cfa-6da3-4851-9a9b-0c7a2c181c37
Co-authored-by: Amp <amp@ampcode.com>
- Removed unused typing imports from admin.py, conditions.py, emails.py, and indicators.py
- These imports became unused after migrating to PEP 604 union syntax
- Updated Python version requirement from 3.9+ to 3.10+
- Added Django 6.0 to supported versions
- Updated test matrix to reflect Python 3.10-3.14
- Added note about PEP 604 union syntax in type hints
Copy link
Contributor

sourcery-ai bot commented Oct 24, 2025
edited
Loading

Reviewer's Guide

This PR updates supported Python and Django versions by dropping Python 3.9, adding Python 3.14 and Django 6.0, modernizes type hints to PEP 604 syntax, and adjusts CI/CD and documentation to align with the new requirements.

Class diagram for modernized type annotations in djangocms_versioning

classDiagram
 class BaseVersionableItem {
 +concrete: bool
 +content_model: type[models.Model]
 +content_admin_mixin: type | None
 +__init__(content_model: type[models.Model], content_admin_mixin: type | None = None)
 }
 class VersionableItem {
 +grouper_field_name: str
 +copy_function: callable
 +extra_grouping_fields: Iterable[str] | None
 +version_list_filter_lookups: dict[str, Any] | None
 +grouper_admin_mixin: type | None
 +content_admin_mixin: type | None
 +preview_url
 +__init__(content_model: type[models.Model], grouper_field_name: str, copy_function: callable, extra_grouping_fields: Iterable[str] | None = None, version_list_filter_lookups: dict[str, Any] | None = None, grouper_admin_mixin: type | None = None, content_admin_mixin: type | None = None, preview_url = None)
 +grouper_choices_queryset() models.QuerySet
 +get_grouper_with_fallbacks(grouper_id) models.Model | None
 +_get_content_types() set[int]
 }
 class VersionableItemAlias {
 +to: BaseVersionableItem
 +__init__(content_model: type[models.Model], to: BaseVersionableItem, content_admin_mixin: type | None = None)
 }
 BaseVersionableItem <|-- VersionableItem
 BaseVersionableItem <|-- VersionableItemAlias
 class VersioningPageToolbar {
 +page_content: PageContent | None
 +__init__(*args, **kwargs)
 +get_page_content(language: str | None = None) PageContent
 }
 class Admin {
 +get_versioning_state(obj: models.Model) str | None
 +get_author(obj: models.Model) str | None
 +get_modified_date(obj: models.Model) str | None
 }
 class Helpers {
 +replace_admin_for_models(pairs: tuple[type[models.Model], type], admin_site: admin.AdminSite | None = None)
 +register_versionadmin_proxy(versionable, admin_site: admin.AdminSite | None = None)
 +get_preview_url(content_obj: models.Model, language: str | None = None) str
 }
 class Conditions {
 +__add__(other: list) Conditions
 +__get__(instance: object, cls) Conditions | BoundConditions
 }
 class Emails {
 +get_full_url(location: str, site: Site | None = None) str
 }
 class Indicators {
 +content_indicator(content_obj: models.Model, versions: list[Version] | None = None) str | None
 }
Loading

File-Level Changes

Change Details Files
Update Python version support
  • Set requires-python to >=3.10
  • Add Python 3.10–3.14 classifiers
  • Remove Python 3.9 support
pyproject.toml
Add Django 6.0 support
  • Introduce Django 6.0 classifier
  • Create tests/requirements/dj60_cms50.txt for Django 6.0
pyproject.toml
tests/requirements/dj60_cms50.txt
Modernize type annotations
  • Replace typing.Union and Optional with PEP 604 union syntax
  • Remove unused typing imports
djangocms_versioning/admin.py
djangocms_versioning/emails.py
djangocms_versioning/conditions.py
djangocms_versioning/helpers.py
djangocms_versioning/cms_toolbars.py
djangocms_versioning/indicators.py
djangocms_versioning/datastructures.py
Revise CI/CD configurations
  • Extend GitHub Actions matrix with Python 3.13–3.14 and Django 6.0 plus exclusion rules
  • Update tox.ini envlist and basepython interpreters to reflect new versions
.github/workflows/test.yml
tox.ini
Refresh documentation
  • Update AGENTS.md with new Python/Django requirements
  • Add guidance for PEP 604 union syntax
AGENTS.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • The GitHub Actions matrix has grown quite verbose—consider switching to an include-based matrix or templated jobs to reduce duplication and avoid mismatched Python/Django combinations.
  • After bumping requires-python to >=3.10, double-check that all dev tooling (e.g., tox envs, local setup docs) no longer reference Python 3.9 and still run correctly under the new minimum.
  • AGENTS.md is a very large AI-specific guide in the repo root—consider moving it to a .github or docs/ directory to keep the root directory focused on code.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The GitHub Actions matrix has grown quite verbose—consider switching to an include-based matrix or templated jobs to reduce duplication and avoid mismatched Python/Django combinations.
- After bumping requires-python to >=3.10, double-check that all dev tooling (e.g., tox envs, local setup docs) no longer reference Python 3.9 and still run correctly under the new minimum.
- AGENTS.md is a very large AI-specific guide in the repo root—consider moving it to a .github or docs/ directory to keep the root directory focused on code.
## Individual Comments
### Comment 1
<location> `djangocms_versioning/helpers.py:73` </location>
<code_context>
-def replace_admin_for_models(pairs: tuple[type[models.Model], type], admin_site: Optional[admin.AdminSite] = None):
+def replace_admin_for_models(pairs: tuple[type[models.Model], type], admin_site: admin.AdminSite | None = None):
 """
 :param models: List of (model class, admin mixin class) tuples
</code_context>
<issue_to_address>
**issue:** Tuple type hint may be too restrictive for multiple pairs.
Consider updating the type hint to `Iterable[tuple[type[models.Model], type]]` if multiple pairs are expected, to better reflect the intended input.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

sourcery-ai[bot] reacted with thumbs up emoji sourcery-ai[bot] reacted with thumbs down emoji
Copy link

codecov bot commented Oct 24, 2025
edited
Loading

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.66%. Comparing base (a132204) to head (3860cd3).
⚠️ Report is 15 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@
## master #489 +/- ##
==========================================
+ Coverage 90.55% 93.66% +3.10% 
==========================================
 Files 72 76 +4 
 Lines 2732 2684 -48 
 Branches 322 0 -322 
==========================================
+ Hits 2474 2514 +40 
+ Misses 182 170 -12 
+ Partials 76 0 -76 

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Replace pip with uv for faster dependency installation
- Add astral-sh/setup-uv@v5 action to all workflows
- Use 'uv pip install --system' for package installation
- Use 'uvx ruff' for linting workflow
- Updated all test jobs: sqlite, postgres, mysql, cms-develop, django-main
Amp-Thread-ID: https://ampcode.com/threads/T-cdf01cfa-6da3-4851-9a9b-0c7a2c181c37
Co-authored-by: Amp <amp@ampcode.com>
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

New security issues found

sourcery-ai[bot] reacted with thumbs up emoji sourcery-ai[bot] reacted with thumbs down emoji
- Add note about using uv for faster dependency installation
- Update testing command to use 'uv pip install'
- Document uv as the package manager in Code Style section
- Change from 'tuple[type[models.Model], type]' to 'Iterable[tuple[type[models.Model], type]]'
- The function expects multiple pairs, not a single tuple
- Also fixed docstring parameter name from 'models' to 'pairs'
- Break function signature across multiple lines to comply with 120 char limit
- Fixes ruff E501 error
pyproject.toml Outdated
]
dependencies = [
"Django>=4.2",
"Django>=6.0a1,<6.1",
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the Django dependency from here. It is implied by the django-cms dependency which in turn "knows" what Django version it needs.


Django>=6.0a1,<6.1
django-classy-tags
django-fsm>=2.6,<3
Copy link
Member

@fsbraun fsbraun Oct 25, 2025
edited
Loading

Choose a reason for hiding this comment

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

This will fail. django-fsm does not support Django 6 without going to a version which will loudly advertises its end-of-life and to migrate to django-viewflow - a no-go imho.

@marksweb, @vinitkumar : We have to make a decision:

  1. Integrate the django-fsm functionality into djangocms-versioning (I made a proposal ages ago here which also integrates versioning's conditions framework: https://github.com/fsbraun/django-state-manager), or
  2. Migrate to django-fsm-2, which is a fork of django-fsm maintained by Django Commons. I already have a PR merged there for Django 6.0 Support (feat: Add support for Django 6.0 django-commons/django-fsm-2#72 ), and I will advocate for a release.

I would like to support option 2 (with the fallback on option 1 - if necessary for any reason in the future)

Copy link
Member Author

@vinitkumar vinitkumar Oct 25, 2025

Choose a reason for hiding this comment

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

@fsbraun @marksweb I like the second option. Less maintenance overhead.

fsbraun reacted with thumbs up emoji
Copy link
Member

fsbraun commented Oct 25, 2025

@vinitkumar Can you take a look at #480 before we merge this? (Might contain some 3.9-specific from __future__ import ... lines).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@fsbraun fsbraun fsbraun left review comments

@sourcery-ai sourcery-ai[bot] sourcery-ai[bot] requested changes

@marksweb marksweb marksweb approved these changes

Requested changes must be addressed to merge this pull request.

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /