feat: bkpaas-auth supports django 5.x#251
Conversation
There was a problem hiding this comment.
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.0to>=4.2,<6.0to 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.
| for django in django_versions: | ||
| session.install(f"django{django}") | ||
| session.run("pytest", *session.posargs) |
There was a problem hiding this comment.
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.
wklken
left a comment
There was a problem hiding this comment.
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
- SQLite Version Handling - Good solution for Django 5.x's SQLite 3.31.0 requirement with graceful fallback to pysqlite3-binary
- Appropriate Version Bump - Minor version increase (3.2.0) correctly reflects new feature addition
- 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
-
Error Handling - The silent
except CommandFailedfor pysqlite3-binary could lead to confusing failures. Consider adding a warning message. -
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
- What's the rationale for dropping Python 3.9? It's supported until October 2025.
- Can you confirm tests pass with both Django 4.2.x and 5.x on all Python versions?
- 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.
No description provided.