Skip to content

Commit

Permalink
update to django 3.1, remove python 2.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswilm committed Aug 11, 2020
1 parent 9a290fb commit 67480a3
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 62 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ after_success:

matrix:
include:
- python: 2.7
env: TOX_ENV="dj111-py27,py27-flake8"
- python: 3.4
env: TOX_ENV="dj111-py34,dj200-py34"
- python: 3.5
env: TOX_ENV="dj111-py35,dj200-py35,dj210-py35,dj220-py35"
env: TOX_ENV="dj220-py35,dj300-py35"
- python: 3.6
env: TOX_ENV="dj111-py36,dj200-py36,dj210-py36,dj220-py36"
env: TOX_ENV="dj220-py36"
- python: 3.7
env: TOX_ENV="dj111-py37,dj200-py37,dj210-py37,dj220-py37,py37-flake8,docs"
env: TOX_ENV="dj220-py37,dj300-py37,dj310-py37,py37-flake8"
- python: 3.8
env: TOX_ENV="dj220-py38,dj300-py38,dj310-py38,py38-flake8,docs"

# Adding sudo: False tells Travis to use their container-based infrastructure, which is somewhat faster.
sudo: False
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ For full docs, see https://cache-machine.readthedocs.org/en/latest/.
Requirements
------------

Cache Machine works with Django 1.11-2.2 and Python 2.7, 3.4, 3.5, 3.6, and 3.7.
Cache Machine works with Django 2.2-3.1 and Python 3.5, 3.6, 3.7 and 3.8.


Installation
Expand All @@ -35,5 +35,5 @@ Get it from `github <http://github.com/django-cache-machine/django-cache-machine

git clone git://github.com/django-cache-machine/django-cache-machine.git
cd django-cache-machine
pip install -r requirements/py3.txt # or py2.txt for Python 2
pip install -r requirements.txt
python run_tests.py
19 changes: 4 additions & 15 deletions caching/base.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
from __future__ import unicode_literals

import functools
import logging

import django
from django.core.cache.backends.base import DEFAULT_TIMEOUT
from django.db import models
from django.db.models import signals
from django.db.models.sql import EmptyResultSet, query
from django.db.models.sql import query
from django.core.exceptions import EmptyResultSet
from django.utils import encoding

from caching import config
from caching.invalidation import byid, cache, flush_key, invalidator, make_key

try:
# ModelIterable is defined in Django 1.9+, and if it's present, we use it
# iterate over our results.
from django.db.models.query import ModelIterable
except ImportError:
# If not, define a Django 1.8-compatible stub we can use instead.
class ModelIterable(object):
def __init__(self, queryset):
self.queryset = queryset

def __iter__(self):
return super(CachingQuerySet, self.queryset).iterator()
from django.db.models.query import ModelIterable


log = logging.getLogger('caching')

Expand Down
2 changes: 0 additions & 2 deletions caching/ext.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.conf import settings
from django.utils import encoding
from jinja2 import nodes
Expand Down
10 changes: 4 additions & 6 deletions caching/invalidation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import collections
import functools
import hashlib
Expand All @@ -10,8 +8,8 @@
from django.core.cache import cache as default_cache
from django.core.cache import caches
from django.core.cache.backends.base import InvalidCacheBackendError
from django.utils import encoding, six, translation
from django.utils.six.moves.urllib.parse import parse_qsl
from django.utils import encoding,translation
from urllib.parse import parse_qsl

from caching import config

Expand Down Expand Up @@ -41,12 +39,12 @@ def make_key(k, with_locale=True):

def flush_key(obj):
"""We put flush lists in the flush: namespace."""
key = obj if isinstance(obj, six.string_types) else obj.get_cache_key(incl_db=False)
key = obj if isinstance(obj, str) else obj.get_cache_key(incl_db=False)
return config.FLUSH + make_key(key, with_locale=False)


def byid(obj):
key = obj if isinstance(obj, six.string_types) else obj.cache_key
key = obj if isinstance(obj, str) else obj.cache_key
return make_key('byid:' + key)


Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions requirements/py2.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/py3.txt

This file was deleted.

4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Software Development :: Libraries :: Python Modules',
]
)
1 change: 0 additions & 1 deletion tests/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import unicode_literals
import jinja2
import logging
import pickle
Expand Down
9 changes: 1 addition & 8 deletions tests/testapp/models.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
from __future__ import unicode_literals

import django
from django.db import models
from django.utils import six
from caching.base import CachingMixin, CachingManager, cached_method

if six.PY3:
from unittest import mock
else:
import mock
from unittest import mock


# This global call counter will be shared among all instances of an Addon.
Expand Down
26 changes: 11 additions & 15 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,27 @@

[tox]
envlist =
dj{111}-py{27,34,35,36,37}
dj{200}-py{34,35,36,37}
dj{210}-py{35,36,37}
dj{220}-py{35,36,37}
py{27,37}-flake8
dj{300}-py{35,36,37,38}
dj{310}-py{35,36,37,38}
py{37,38}-flake8
docs

[testenv]
basepython =
py27: python2.7
py34: python3.4
py35: python3.5
py36: python3.6
py37: python3.7
py38: python3.8
commands = {envpython} run_tests.py --with-coverage
deps =
py27: -rrequirements/py2.txt
py{34,35,36,37}: -rrequirements/py3.txt
dj111: Django>=1.11,<2.0
dj200: Django>=2.0,<2.1
dj210: Django>=2.1,<2.2
dj220: Django==2.2b1
py{35,36,37,38}: -rrequirements.txt
dj220: Django>=2.2,<3.0
dj300: Django>=3.0,<3.1
dj310: Django>=3.1,<3.2

[testenv:docs]
basepython = python3.7
basepython = python3.8
deps =
Sphinx
Django
Expand All @@ -39,10 +35,10 @@ setenv =
changedir = docs
commands = /usr/bin/make html

[testenv:py27-flake8]
[testenv:py37-flake8]
deps = flake8
commands = flake8

[testenv:py37-flake8]
[testenv:py38-flake8]
deps = flake8
commands = flake8

0 comments on commit 67480a3

Please sign in to comment.