-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Update test scope to include django 5.1, update pre-commit hooks #683
Conversation
Signed-off-by: Kwong Tung Nan <[email protected]>
Signed-off-by: Kwong Tung Nan <[email protected]>
Signed-off-by: Kwong Tung Nan <[email protected]>
Signed-off-by: Kwong Tung Nan <[email protected]>
Reviewer's Guide by SourceryThis pull request updates the test scope to include Django 5.1 and adjusts the code to accommodate changes in Django 5.1, specifically the removal of support for 'index_together' in meta classes. It also updates the pre-commit hooks and modifies the test configurations to ensure compatibility with the new Django version. No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @kwongtn - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider keeping pyright type checking enabled for tests/relay/mptt/models.py if possible, as it could help catch potential issues earlier. If there are specific reasons for excluding it, perhaps add a comment explaining why.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
pyproject.toml
Outdated
@@ -177,7 +177,7 @@ max-nested-blocks = 7 | |||
[tool.pyright] | |||
pythonVersion = "3.9" | |||
useLibraryCodeForTypes = true | |||
exclude = [".venv", "**/migrations", "dist", "docs"] | |||
exclude = [".venv", "**/migrations", "dist", "docs", "tests/relay/mptt/models.py"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question (testing): Could you explain why this specific test file needs to be excluded from type checking?
Excluding test files from type checking might hide potential issues. If there's a specific reason for this exclusion, it would be helpful to document it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to exclude the whole file for this? Can we just # type: ignore
or cast
in the lines that need that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, using # type: ignore
or cast
on the specific lines causing type errors would be a better approach than excluding the entire file. This way, we maintain type checking for the rest of the test file and only bypass it where absolutely necessary. Could you please update the PR with these more granular type ignores/casts? This will help us catch any potential type errors in the other parts of the test file. Thanks!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #683 +/- ##
=======================================
Coverage 89.17% 89.17%
=======================================
Files 41 41
Lines 3778 3778
=======================================
Hits 3369 3369
Misses 409 409 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty for this! :)
Left a couple of suggestions/questions
include: | ||
# Django 4.2 only supports python 3.8-3.12 | ||
- django-version: 4.2.* | ||
python-version: '3.8' | ||
mode: std | ||
- django-version: 4.2.* | ||
python-version: '3.8' | ||
mode: geos | ||
exclude: | ||
# Django 5.0 only supports python 3.10+ | ||
# Django 4.2 only supports python 3.8-3.12 | ||
- django-version: 4.2.* | ||
python-version: '3.13' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: How does this works when we have both include
and exclude
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, they are not mutually exclusive. And according to docs
All include combinations are processed after exclude. This allows you to use include to add back combinations that were previously excluded.
Exclude works by excluding anything that matches the declared params.
For example as of the above, it excludes Django 4.2 and Python 3.13, no matter if it is geo or standard.
As for include, I added it in as it'll be redundant to add Python 3.8 to the matrix, then exclude all except Django 4.2 😅
pyproject.toml
Outdated
@@ -177,7 +177,7 @@ max-nested-blocks = 7 | |||
[tool.pyright] | |||
pythonVersion = "3.9" | |||
useLibraryCodeForTypes = true | |||
exclude = [".venv", "**/migrations", "dist", "docs"] | |||
exclude = [".venv", "**/migrations", "dist", "docs", "tests/relay/mptt/models.py"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to exclude the whole file for this? Can we just # type: ignore
or cast
in the lines that need that?
tests/relay/mptt/models.py
Outdated
|
||
if django.VERSION >= (5, 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: why is this needed?
Can you add a comment with the explanation, and also pointing out where this code came from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out its not needed anymore 🥳
According to django mptt repo, django-mptt
is now unmaintained. It recommends using django-tree-queries instead.
Hence I tried using it, and guess what all tests pass 😁
Will be deprecating django-mptt
and removing references in an upcoming PR
Co-authored-by: Thiago Bellini Ribeiro <[email protected]>
Co-authored-by: Thiago Bellini Ribeiro <[email protected]>
Signed-off-by: Kwong Tung Nan <[email protected]>
Signed-off-by: Kwong Tung Nan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty! :)
Description
Update test scope & pre-commit hooks.
Replaced
django-mptt
withdjango-tree-queries
Types of Changes
Issues Fixed or Closed by This PR
Checklist
Summary by Sourcery
Extend support to Django 5.1 and update pre-commit hooks.
Enhancements:
Tests: