Skip to content

Commit

Permalink
Add Django 4.0 support, drop Python 3.6 and Django 3.1 (#208)
Browse files Browse the repository at this point in the history
* Fix tox.ini and use exclude for ci.yml
* runtests_urls.py had an issue from using pre-Django 2.2 import of urls
* tox.ini forgot to remove 3.7 from Django 4.0 env
* Use re_path
* Avoid system error in Django test
* Fix read/test_union.py
* Test assertion error for read/test_union
* Fix remaining read/test_intersection test
* Bump version
  • Loading branch information
Andrew-Chen-Wang authored Dec 7, 2021
1 parent a9c5d4d commit f1087da
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 37 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
django-version: ['2.2', '3.1', '3.2']
python-version: ['3.7', '3.8', '3.9', '3.10']
django-version: ['2.2', '3.2', '4.0']
exclude:
- python-version: '3.10'
django-version: '2.2'
- python-version: '3.7'
django-version: '4.0'

services:
redis:
Expand Down Expand Up @@ -66,7 +71,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get install -y libmemcached-dev zlib1g-dev
python -m pip install --upgrade pip
python -m pip install --upgrade pip wheel
python -m pip install tox tox-gh-actions coveralls
- name: Tox Test
run: tox
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

services:
redis:
image: redis:6.0
image: redis:6
ports:
- 6379:6379
postgres:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get install -y libmemcached-dev zlib1g-dev
python -m pip install --upgrade pip
python -m pip install --upgrade pip wheel
python -m pip install tox tox-gh-actions coveralls
- name: Tox Test
run: tox
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
What’s new in django-cachalot?
==============================

2.4.5
-----

- Dropped Python 3.6 and Django 3.1 support. Added Django 4.0 support (#208)

2.4.4
-----

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Table of Contents:
Quickstart
----------

Cachalot officially supports Python 3.6-3.9 and Django 2.2 and 3.1-3.2 with the databases PostgreSQL, SQLite, and MySQL.
Cachalot officially supports Python 3.7-3.10 and Django 2.2, 3.2, and 4.0 with the databases PostgreSQL, SQLite, and MySQL.

Note: an upper limit on Django version is set for your safety. Please do not ignore it.

Expand Down
2 changes: 1 addition & 1 deletion cachalot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (2, 4, 4)
VERSION = (2, 4, 5)
__version__ = ".".join(map(str, VERSION))

try:
Expand Down
12 changes: 4 additions & 8 deletions cachalot/tests/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django import VERSION as DJANGO_VERSION
from django.conf import settings
from django.contrib.postgres.fields import (
ArrayField, HStoreField, IntegerRangeField,
Expand All @@ -10,11 +11,8 @@
def extra_regular_available_fields():
fields = []
try:
# TODO Add to module import when Dj40 dropped
from django import VERSION as DJANGO_VERSION
from django.contrib.postgres.fields import JSONField
if float(".".join(map(str, DJANGO_VERSION[:2]))) > 3.0:
fields.append(('json', JSONField(null=True, blank=True)))
from django.db.models import JSONField
fields.append(('json', JSONField(null=True, blank=True)))
except ImportError:
pass

Expand All @@ -38,12 +36,10 @@ def extra_postgres_available_fields():
pass

# Future proofing with Django 40 deprecation
try:
if DJANGO_VERSION[0] < 4:
# TODO Remove when Dj40 support is dropped
from django.contrib.postgres.fields import JSONField
fields.append(('json', JSONField(null=True, blank=True)))
except ImportError:
pass

return fields

Expand Down
5 changes: 2 additions & 3 deletions cachalot/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django import VERSION as DJANGO_VERSION
from django.conf import settings
from django.contrib.postgres.fields import (
ArrayField, HStoreField,
Expand Down Expand Up @@ -53,11 +54,9 @@ class PostgresModel(Model):
null=True, blank=True)

hstore = HStoreField(null=True, blank=True)
try:
if DJANGO_VERSION[0] < 4:
from django.contrib.postgres.fields import JSONField
json = JSONField(null=True, blank=True)
except ImportError:
pass

int_range = IntegerRangeField(null=True, blank=True)
try:
Expand Down
4 changes: 2 additions & 2 deletions cachalot/tests/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def test_union(self):
self.assert_query_cached(qs)

with self.assertRaisesMessage(
AssertionError,
AssertionError if django_version[0] < 4 else TypeError,
'Cannot combine queries on two different base models.'):
Test.objects.all() | Permission.objects.all()

Expand Down Expand Up @@ -588,7 +588,7 @@ def test_intersection(self):
self.assert_query_cached(qs)

with self.assertRaisesMessage(
AssertionError,
AssertionError if django_version[0] < 4 else TypeError,
'Cannot combine queries on two different base models.'):
Test.objects.all() & Permission.objects.all()

Expand Down
4 changes: 2 additions & 2 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Quick start
Requirements
............

- Django 2.2, 3.1-3.2
- Python 3.6-3.9
- Django 2.2, 3.2, 4.0
- Python 3.7-3.10
- a cache configured as ``'default'`` with one of these backends:

- `django-redis <https://github.com/niwinz/django-redis>`_
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Django>=2.2,<3.3
Django>=2.2,<4.1
6 changes: 3 additions & 3 deletions runtests_urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import debug_toolbar
from django.conf.urls import url, include
from django.urls import re_path, include
from django.http import HttpResponse


Expand All @@ -8,6 +8,6 @@ def empty_page(request):


urlpatterns = [
url(r'^$', empty_page),
url(r'^__debug__/', include(debug_toolbar.urls)),
re_path(r'^$', empty_page),
re_path(r'^__debug__/', include(debug_toolbar.urls)),
]
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand Down
16 changes: 7 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
[tox]
envlist =
py{36,37,38,39}-django2.2-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{36,37,38,39}-django3.1-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{36,37,38,39,310}-django3.2-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{36,37,38,39,310}-djangomain-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{37,38,39}-django2.2-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{37,38,39,310}-django3.2-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{38,39,310}-django4.0-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{38,39,310}-djangomain-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},

[testenv]
basepython =
py36: python3.6
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
deps =
django2.2: Django>=2.2,<2.3
django3.1: Django>=3.1,<3.2
django3.2: Django>=3.2,<3.3
django3.2: Django>=3.2,<4.0
django4.0: Django>=4.0,<4.1
djangomain: https://github.com/django/django/archive/main.tar.gz
psycopg2-binary>=2.8,<2.9
mysqlclient
Expand All @@ -42,7 +41,6 @@ commands =

[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39
Expand All @@ -51,6 +49,6 @@ python =
[gh-actions:env]
DJANGO =
2.2: django2.2
3.1: django3.1
3.2: django3.2
4.0: django4.0
main: djangomain

0 comments on commit f1087da

Please sign in to comment.