Skip to content
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

Fix Django 4 compatibility issues #778

Merged
merged 4 commits into from
Dec 16, 2021
Merged

Conversation

monty5811
Copy link
Contributor

The where_class argument to the private get_extra_restriction() was changed in Django 4.0.

A simple change is to remove the where_class argument here. But that breaks taggit on lower versions of django.

To fix this, I added a shim that checks the django version and uses the correct function.
I have no idea if this is the best way to fix this, but the tests pass 🤷‍♂️

Relevant issue: #776

Note that this PR has a commit from #777 too.

 - add a shim around `get_extra_restriction` so that it works in
   versions of Django >=4 and <4
 - fixes jazzband#776
# this is required to handle a change in Django 4.0
# https://docs.djangoproject.com/en/4.0/releases/4.0/#miscellaneous
# the signature of the (private) funtion was changed
if django.VERSION > (3, 8):
Copy link
Contributor

Choose a reason for hiding this comment

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

3, 8 or 3, 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, woops, should be (3, 2).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this, I flipped it round to do < (4, 0) instead.

@codecov
Copy link

codecov bot commented Dec 15, 2021

Codecov Report

Merging #778 (2382ebc) into master (4042b85) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #778      +/-   ##
==========================================
+ Coverage   92.39%   92.46%   +0.06%     
==========================================
  Files           9        9              
  Lines         697      703       +6     
  Branches      135      136       +1     
==========================================
+ Hits          644      650       +6     
  Misses         35       35              
  Partials       18       18              
Impacted Files Coverage Δ
taggit/managers.py 95.34% <100.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4042b85...2382ebc. Read the comment docs.

@hramezani
Copy link
Member

Thanks @monty5811 👍

@rtpg
Copy link
Contributor

rtpg commented Dec 16, 2021

Looks good to me too, once we fix up the above comments! Thank you for sending this in 👍

Copy link
Member

@hramezani hramezani left a comment

Choose a reason for hiding this comment

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

LGTM

@auvipy auvipy merged commit d083396 into jazzband:master Dec 16, 2021
@steven-mercatante
Copy link

Hi, when can we expect a new version including this fix to land in pypi?
v2.0.0's last commit was November 16, 2021. Thanks!

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.

5 participants