Skip to content

feat: bkpaas-auth supports django 5.x#251

Merged
piglei merged 2 commits intoTencentBlueKing:masterfrom
piglei:bkpaas-auth-dj5
Jan 14, 2026
Merged

feat: bkpaas-auth supports django 5.x#251
piglei merged 2 commits intoTencentBlueKing:masterfrom
piglei:bkpaas-auth-dj5

Conversation

@piglei
Copy link
Copy Markdown
Collaborator

@piglei piglei commented Jan 12, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for Django 5.x to the bkpaas-auth SDK while dropping support for Python 3.9 and adding support for Python 3.12. The version is bumped from 3.1.3 to 3.2.0 to reflect these changes.

Changes:

  • Updated Django dependency from >=4.2,<5.0 to >=4.2,<6.0 to support Django 5.x
  • Removed Python 3.9 from test matrix and added Python 3.12
  • Added SQLite version checking to ensure Django 5.x requirements are met during testing

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sdks/bkpaas-auth/pyproject.toml Updated version to 3.2.0 and Django dependency to support 5.x
sdks/bkpaas-auth/CHANGES.md Documented the new version with Django 5.x support and Python 3.9 removal
sdks/bkpaas-auth/tests/conftest.py Added SQLite version checking and standardized to double quotes
sdks/bkpaas-auth/noxfile.py Updated Python versions and added Django version matrix testing
.github/workflows/bkpaas-auth.yml Updated CI Python versions to match supported versions
sdks/bkpaas-auth/poetry.lock Updated lock file hash reflecting dependency changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +63 to +65
for django in django_versions:
session.install(f"django{django}")
session.run("pytest", *session.posargs)
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The current implementation installs Django versions sequentially in a loop, but this approach may not properly isolate tests between Django versions. Each session.install for a new Django version will overwrite the previous one, which is correct. However, consider adding logging or separating the test runs more explicitly to make it clear which Django version is being tested. Additionally, the tests should ideally fail fast if one Django version fails rather than continuing to test the next version.

Copilot uses AI. Check for mistakes.
Comment thread sdks/bkpaas-auth/tests/conftest.py
Comment thread sdks/bkpaas-auth/pyproject.toml Outdated
Comment thread sdks/bkpaas-auth/CHANGES.md Outdated
Copy link
Copy Markdown
Collaborator

@wklken wklken left a comment

Choose a reason for hiding this comment

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

PR Review: Django 5.x Support

Summary

This PR adds Django 5.x support while dropping Python 3.9 and adding Python 3.12. Overall approach is good, but there's a critical issue with the Django version testing logic that needs addressing.


✅ Positive Changes

  1. SQLite Version Handling - Good solution for Django 5.x's SQLite 3.31.0 requirement with graceful fallback to pysqlite3-binary
  2. Appropriate Version Bump - Minor version increase (3.2.0) correctly reflects new feature addition
  3. Documentation - CHANGES.md properly updated

⚠️ Critical Issue

noxfile.py Django Version Testing Logic

The current approach in noxfile.py:62-69 has a potential problem:

for django in django_versions:
    session.install(f"django{django}")
    session.run("pytest", *session.posargs)

Problem: Installing Django multiple times in the same session without uninstalling may cause conflicts. The second install might not properly replace Django 4.2.

Recommendation: Use nox parametrization for cleaner separation:

@nox.session(python=ALL_PYTHON)
@nox.parametrize("django", [">=4.2,<5", ">=5.0,<6"])
def tests(session, django):
    install_with_constraints(session, "pytest", "pytest-django", "pytest-mock")
    try:
        session.install("pysqlite3-binary")
    except CommandFailed:
        session.warn("pysqlite3-binary installation failed - tests may fail if SQLite < 3.31.0")
    session.install(f"django{django}")
    session.run("pytest", *session.posargs)

This ensures each Django version runs in a separate session with proper isolation.


📝 Minor Issues

  1. Error Handling - The silent except CommandFailed for pysqlite3-binary could lead to confusing failures. Consider adding a warning message.

  2. Quote Style - The change from single to double quotes in conftest.py seems stylistic, but your black config has skip-string-normalization = 'true'. Is this intentional?


🔍 Questions

  1. What's the rationale for dropping Python 3.9? It's supported until October 2025.
  2. Can you confirm tests pass with both Django 4.2.x and 5.x on all Python versions?
  3. Did the macOS CI fix resolve the SQLite version issues?

Recommendation

Request Changes - Please fix the Django version testing logic to ensure proper isolation between test runs. The other issues are minor but worth addressing.

@piglei piglei merged commit 47e5a91 into TencentBlueKing:master Jan 14, 2026
9 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.

4 participants