diff --git a/.gitignore b/.gitignore index cbb848abf..c0c219be5 100644 --- a/.gitignore +++ b/.gitignore @@ -59,7 +59,6 @@ coverage.xml local_settings.py db.sqlite3 db.sqlite3-journal -.idea/ # Flask stuff: instance/ diff --git a/.travis.yml b/.travis.yml index 3d4021d8d..37ca16384 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,18 +2,16 @@ 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" @@ -21,20 +19,9 @@ env: 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 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6b692a2f9..9b9cc3b19 100644 --- a/CHANGELOG.rst +++ b/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 ----- diff --git a/README.rst b/README.rst index 3ec966695..c96fc9728 100644 --- a/README.rst +++ b/README.rst @@ -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 ---------------------------- diff --git a/cachalot/__init__.py b/cachalot/__init__.py index 903b668b8..9879a164e 100644 --- a/cachalot/__init__.py +++ b/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' diff --git a/cachalot/api.py b/cachalot/api.py index 90df8a522..18110d1fb 100644 --- a/cachalot/api.py +++ b/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 @@ -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) diff --git a/cachalot/apps.py b/cachalot/apps.py index b165063bf..a0ecea0bb 100644 --- a/cachalot/apps.py +++ b/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 @@ -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__, diff --git a/cachalot/cache.py b/cachalot/cache.py index 3fd64dd14..6acde1611 100644 --- a/cachalot/cache.py +++ b/cachalot/cache.py @@ -1,6 +1,3 @@ -# coding: utf-8 - -from __future__ import unicode_literals from collections import defaultdict from threading import local diff --git a/cachalot/monkey_patch.py b/cachalot/monkey_patch.py index 77db96e14..0ea2fd949 100644 --- a/cachalot/monkey_patch.py +++ b/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 @@ -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 @@ -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 \ diff --git a/cachalot/panels.py b/cachalot/panels.py index 3a7033d14..e9df54877 100644 --- a/cachalot/panels.py +++ b/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 diff --git a/cachalot/signals.py b/cachalot/signals.py index 2d0ac207b..56892af98 100644 --- a/cachalot/signals.py +++ b/cachalot/signals.py @@ -1,6 +1,3 @@ -# coding: utf-8 - -from __future__ import unicode_literals from django.dispatch import Signal diff --git a/cachalot/tests/api.py b/cachalot/tests/api.py index b31c6b3f9..aa4373236 100644 --- a/cachalot/tests/api.py +++ b/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 diff --git a/cachalot/tests/migrations/0001_initial.py b/cachalot/tests/migrations/0001_initial.py index 41f11fcde..918cc3e03 100644 --- a/cachalot/tests/migrations/0001_initial.py +++ b/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, diff --git a/cachalot/tests/models.py b/cachalot/tests/models.py index fe109c1f5..fbb0d9ad5 100644 --- a/cachalot/tests/models.py +++ b/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, diff --git a/cachalot/tests/multi_db.py b/cachalot/tests/multi_db.py index e98aaeb2c..e0cfd367e 100644 --- a/cachalot/tests/multi_db.py +++ b/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 diff --git a/cachalot/tests/postgres.py b/cachalot/tests/postgres.py index 634b0f2d6..c89c6fdc2 100644 --- a/cachalot/tests/postgres.py +++ b/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 diff --git a/cachalot/tests/read.py b/cachalot/tests/read.py index 44420f5ee..f9fc03b5f 100644 --- a/cachalot/tests/read.py +++ b/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 diff --git a/cachalot/tests/settings.py b/cachalot/tests/settings.py index 4709c6638..9385bc16a 100644 --- a/cachalot/tests/settings.py +++ b/cachalot/tests/settings.py @@ -1,6 +1,3 @@ -# coding: utf-8 - -from __future__ import unicode_literals from time import sleep from unittest import skipIf diff --git a/cachalot/tests/signals.py b/cachalot/tests/signals.py index 1ee5f0d0f..71e391162 100644 --- a/cachalot/tests/signals.py +++ b/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 diff --git a/cachalot/tests/test_utils.py b/cachalot/tests/test_utils.py index 7b3530dca..9f21f4157 100644 --- a/cachalot/tests/test_utils.py +++ b/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 @@ -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) diff --git a/cachalot/tests/thread_safety.py b/cachalot/tests/thread_safety.py index 30dd2a960..cd7cd6396 100644 --- a/cachalot/tests/thread_safety.py +++ b/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 diff --git a/cachalot/tests/transaction.py b/cachalot/tests/transaction.py index 411aaa7ad..00d7d8257 100644 --- a/cachalot/tests/transaction.py +++ b/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 diff --git a/cachalot/tests/write.py b/cachalot/tests/write.py index f3dff9175..05c1b0523 100644 --- a/cachalot/tests/write.py +++ b/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 diff --git a/cachalot/transaction.py b/cachalot/transaction.py index 8e09c95e1..b8f7b28a5 100644 --- a/cachalot/transaction.py +++ b/cachalot/transaction.py @@ -1,7 +1,3 @@ -# coding: utf-8 - -from __future__ import unicode_literals - from .settings import cachalot_settings diff --git a/cachalot/utils.py b/cachalot/utils.py index fc42d36ab..99ed5a98e 100644 --- a/cachalot/utils.py +++ b/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 @@ -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 @@ -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: @@ -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() diff --git a/requirements.txt b/requirements.txt index 37d10bc70..82a39abb9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -Django>=1.11 -six>=1.13 \ No newline at end of file +Django>=2 \ No newline at end of file diff --git a/tox.ini b/tox.ini index 239f434aa..dea18d066 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,5 @@ [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}, @@ -8,13 +7,11 @@ envlist = [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 @@ -29,7 +26,6 @@ deps = django-debug-toolbar beautifulsoup4 coverage - six setenv = sqlite3: DB_ENGINE=sqlite3 postgresql: DB_ENGINE=postgresql @@ -44,7 +40,6 @@ commands = [travis:env] DJANGO = - 1.11: django1.11 2.0: django2.0 2.1: django2.1 2.2: django2.2