Skip to content

Commit

Permalink
Drop support for Py2.7 and Dj 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-Chen-Wang committed Jun 11, 2020
1 parent a611950 commit ba5c519
Show file tree
Hide file tree
Showing 27 changed files with 18 additions and 113 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -59,7 +59,6 @@ coverage.xml
local_settings.py
db.sqlite3
db.sqlite3-journal
.idea/

# Flask stuff:
instance/
Expand Down
15 changes: 1 addition & 14 deletions .travis.yml
Expand Up @@ -2,39 +2,26 @@ language: python

services:
- memcached
- redis-server
- redis
- mysql
- postgresql

python:
- "2.7"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
env:
- DJANGO="1.11"
- DJANGO="2.0"
- DJANGO="2.1"
- DJANGO="2.2"
- DJANGO="3.0"

matrix:
exclude:
- python: 2.7
env: DJANGO=2.0
- python: 2.7
env: DJANGO=2.1
- python: 2.7
env: DJANGO=2.2
- python: 2.7
env: DJANGO=3.0

- python: 3.5
env: DJANGO=3.0

- python: 3.8
env: DJANGO=1.11
- python: 3.8
env: DJANGO=2.0
- python: 3.8
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.rst
@@ -1,6 +1,11 @@
What’s new in django-cachalot?
==============================

2.3.0
-----

- Drop support for Django 1.11 and Python 2.7

2.2.0
-----

Expand Down
4 changes: 1 addition & 3 deletions README.rst
Expand Up @@ -27,12 +27,10 @@ Documentation: http://django-cachalot.readthedocs.io
Quickstart
----------

Cachalot officially supports Python 2.7, 3.4-3.8 and Django 1.11, 2.0-2.2, 3.0 with the databases PostgreSQL, SQLite, and MySQL.
Cachalot officially supports Python 3.5-3.8 and Django 2.0-2.2, 3.0 with the databases PostgreSQL, SQLite, and MySQL.

Note 1: Python 3.4 with MySQL fails on tests. If your MySQL is configured correctly, then it may work.

Note 2: Python 3.5 with Django 1.11 in tests prove to occasionally have performance issues.

Third-Party Cache Comparison
----------------------------

Expand Down
2 changes: 1 addition & 1 deletion cachalot/__init__.py
@@ -1,4 +1,4 @@
VERSION = (2, 2, 0)
VERSION = (2, 3, 0)
__version__ = '.'.join(map(str, VERSION))

default_app_config = 'cachalot.apps.CachalotConfig'
12 changes: 2 additions & 10 deletions cachalot/api.py
@@ -1,14 +1,6 @@
# coding: utf-8

from __future__ import unicode_literals

from django.apps import apps
from django.conf import settings
from django.db import connections
try:
from django.utils.six import string_types
except ImportError:
from six import string_types

from .cache import cachalot_caches
from .settings import cachalot_settings
Expand All @@ -34,12 +26,12 @@ def _cache_db_tables_iterator(tables, cache_alias, db_alias):

def _get_tables(tables_or_models):
for table_or_model in tables_or_models:
if isinstance(table_or_model, string_types) and '.' in table_or_model:
if isinstance(table_or_model, str) and '.' in table_or_model:
try:
table_or_model = apps.get_model(table_or_model)
except LookupError:
pass
yield (table_or_model if isinstance(table_or_model, string_types)
yield (table_or_model if isinstance(table_or_model, str)
else table_or_model._meta.db_table)


Expand Down
4 changes: 1 addition & 3 deletions cachalot/apps.py
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django import __version__ as django__version__, VERSION as django_version
from django.apps import AppConfig
from django.conf import settings
Expand All @@ -13,7 +11,7 @@

@register(Tags.compatibility)
def check_django_version(app_configs, **kwargs):
if not (1, 11) <= django_version < (3, 1):
if not (2, 0) <= django_version < (3, 1):
return [Error(
'Django %s is not compatible with this version of django-cachalot.'
% django__version__,
Expand Down
3 changes: 0 additions & 3 deletions cachalot/cache.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
from collections import defaultdict
from threading import local

Expand Down
11 changes: 2 additions & 9 deletions cachalot/monkey_patch.py
@@ -1,7 +1,5 @@
# coding: utf-8

from __future__ import unicode_literals
from collections import Iterable
from functools import wraps
from time import time

from django.db.backends.utils import CursorWrapper
Expand All @@ -12,11 +10,6 @@
)
from django.db.transaction import Atomic, get_connection

try:
from django.utils.six import binary_type, wraps
except ImportError:
from six import binary_type, wraps

from .api import invalidate
from .cache import cachalot_caches
from .settings import cachalot_settings, ITERABLES
Expand Down Expand Up @@ -129,7 +122,7 @@ def inner(cursor, sql, *args, **kwargs):
finally:
connection = cursor.db
if getattr(connection, 'raw', True):
if isinstance(sql, binary_type):
if isinstance(sql, bytes):
sql = sql.decode('utf-8')
sql = sql.lower()
if 'update' in sql or 'insert' in sql or 'delete' in sql \
Expand Down
5 changes: 1 addition & 4 deletions cachalot/panels.py
@@ -1,13 +1,10 @@
# coding: utf-8

from __future__ import unicode_literals
from collections import defaultdict
from datetime import datetime

from debug_toolbar.panels import Panel
from django.apps import apps
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.utils.timesince import timesince

from .cache import cachalot_caches
Expand Down
3 changes: 0 additions & 3 deletions cachalot/signals.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
from django.dispatch import Signal


Expand Down
3 changes: 0 additions & 3 deletions cachalot/tests/api.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
from time import time, sleep
from unittest import skipIf

Expand Down
4 changes: 0 additions & 4 deletions cachalot/tests/migrations/0001_initial.py
@@ -1,7 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals

from django.conf import settings
from django.contrib.postgres.fields import (
ArrayField, HStoreField, IntegerRangeField, JSONField, FloatRangeField,
Expand Down
4 changes: 0 additions & 4 deletions cachalot/tests/models.py
@@ -1,7 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals

from django.conf import settings
from django.contrib.postgres.fields import (
ArrayField, HStoreField,
Expand Down
3 changes: 0 additions & 3 deletions cachalot/tests/multi_db.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
from unittest import skipIf

from django import VERSION as DJANGO_VERSION
Expand Down
3 changes: 0 additions & 3 deletions cachalot/tests/postgres.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
from datetime import date, datetime
from decimal import Decimal
from unittest import skipUnless
Expand Down
3 changes: 0 additions & 3 deletions cachalot/tests/read.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
import datetime
from unittest import skipIf
from uuid import UUID
Expand Down
3 changes: 0 additions & 3 deletions cachalot/tests/settings.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
from time import sleep
from unittest import skipIf

Expand Down
3 changes: 0 additions & 3 deletions cachalot/tests/signals.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
from unittest import skipIf

from django.conf import settings
Expand Down
6 changes: 1 addition & 5 deletions cachalot/tests/test_utils.py
@@ -1,10 +1,6 @@
from django import VERSION as DJANGO_VERSION
from django.core.management.color import no_style
from django.db import connection, transaction
try:
from django.utils.six import string_types
except ImportError:
from six import string_types

from .models import PostgresModel
from ..utils import _get_tables
Expand Down Expand Up @@ -35,7 +31,7 @@ def force_repoen_connection(self):
connection.cursor()

def assert_tables(self, queryset, *tables):
tables = {table if isinstance(table, string_types)
tables = {table if isinstance(table, str)
else table._meta.db_table for table in tables}
self.assertSetEqual(_get_tables(queryset.db, queryset.query), tables)

Expand Down
3 changes: 0 additions & 3 deletions cachalot/tests/thread_safety.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
from threading import Thread

from django.db import connection, transaction
Expand Down
4 changes: 0 additions & 4 deletions cachalot/tests/transaction.py
@@ -1,7 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals

from django.contrib.auth.models import User
from django.db import transaction, connection, IntegrityError
from django.test import TransactionTestCase, skipUnlessDBFeature
Expand Down
3 changes: 0 additions & 3 deletions cachalot/tests/write.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
from unittest import skipIf, skipUnless

from django import VERSION as DJANGO_VERSION
Expand Down
4 changes: 0 additions & 4 deletions cachalot/transaction.py
@@ -1,7 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals

from .settings import cachalot_settings


Expand Down
12 changes: 2 additions & 10 deletions cachalot/utils.py
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import unicode_literals
import datetime
from decimal import Decimal
from hashlib import sha1
Expand All @@ -13,10 +10,6 @@
from django.db.models.functions import Now
from django.db.models.sql import Query, AggregateQuery
from django.db.models.sql.where import ExtraWhere, WhereNode, NothingNode
try:
from django.utils.six import text_type, binary_type, integer_types
except ImportError:
from six import text_type, binary_type, integer_types

from .settings import ITERABLES, cachalot_settings
from .transaction import AtomicCache
Expand All @@ -31,10 +24,9 @@ class IsRawQuery(Exception):


CACHABLE_PARAM_TYPES = {
bool, int, float, Decimal, bytearray, binary_type, text_type, type(None),
bool, int, float, Decimal, bytearray, type(None),
datetime.date, datetime.time, datetime.datetime, datetime.timedelta, UUID,
}
CACHABLE_PARAM_TYPES.update(integer_types) # Adds long for Python 2
UNCACHABLE_FUNCS = {Now, TransactionNow}

try:
Expand Down Expand Up @@ -79,7 +71,7 @@ def get_query_cache_key(compiler):
sql, params = compiler.as_sql()
check_parameter_types(params)
cache_key = '%s:%s:%s' % (compiler.using, sql,
[text_type(p) for p in params])
[str(p) for p in params])
return sha1(cache_key.encode('utf-8')).hexdigest()


Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
@@ -1,2 +1 @@
Django>=1.11
six>=1.13
Django>=2
5 changes: 0 additions & 5 deletions tox.ini
@@ -1,20 +1,17 @@
[tox]
envlist =
py{27,35,36,37}-django1.11-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{35,36,37}-django2.0-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{35,36,37}-django2.1-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{35,36,37,38}-django2.2-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},
py{36,37,38}-django3.0-{sqlite3,postgresql,mysql}-{redis,memcached,pylibmc,locmem,filebased},

[testenv]
basepython =
py27: python2.7
py35: python3.5
py36: python3.6
py37: python3.7
py38: python3.8
deps =
django1.11: Django>=1.11,<1.12
django2.0: Django>=2.0,<2.1
django2.1: Django>=2.1,<2.2
django2.2: Django>=2.2,<2.3
Expand All @@ -29,7 +26,6 @@ deps =
django-debug-toolbar
beautifulsoup4
coverage
six
setenv =
sqlite3: DB_ENGINE=sqlite3
postgresql: DB_ENGINE=postgresql
Expand All @@ -44,7 +40,6 @@ commands =

[travis:env]
DJANGO =
1.11: django1.11
2.0: django2.0
2.1: django2.1
2.2: django2.2
Expand Down

0 comments on commit ba5c519

Please sign in to comment.