From 6e22dc7f58274eab06db2cefaf2a2f38b58b7dce Mon Sep 17 00:00:00 2001 From: Andrew-Chen-Wang Date: Thu, 18 Jun 2020 09:28:00 -0400 Subject: [PATCH] Drop Python 2.7 and Dj 1.11 --- .gitignore | 1 - .travis.yml | 17 +---------------- CHANGELOG.rst | 5 +++++ README.rst | 8 +------- benchmark.py | 4 ---- cachalot/api.py | 12 ++---------- cachalot/apps.py | 4 +--- cachalot/cache.py | 3 --- cachalot/monkey_patch.py | 11 ++--------- cachalot/panels.py | 5 +---- cachalot/signals.py | 3 --- cachalot/tests/migrations/0001_initial.py | 4 ---- cachalot/tests/models.py | 4 ---- cachalot/tests/multi_db.py | 3 --- cachalot/tests/postgres.py | 3 --- cachalot/tests/read.py | 3 --- cachalot/tests/settings.py | 3 --- cachalot/tests/signals.py | 3 --- cachalot/tests/test_utils.py | 6 +----- cachalot/tests/thread_safety.py | 3 --- cachalot/tests/transaction.py | 4 ---- cachalot/tests/write.py | 3 --- cachalot/transaction.py | 4 ---- cachalot/utils.py | 12 ++---------- docs/index.rst | 2 +- docs/quickstart.rst | 10 +++++----- docs/reporting.rst | 4 ++-- requirements.txt | 3 +-- setup.py | 6 +++--- tox.ini | 5 ----- 30 files changed, 28 insertions(+), 130 deletions(-) diff --git a/.gitignore b/.gitignore index cbb848a..c0c219b 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 3d4021d..29aded6 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,27 +19,14 @@ 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 env: DJANGO=2.1 -sudo: false - cache: pip install: pip install tox tox-travis coveralls diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6b692a2..9b9cc3b 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 bbd2e55..ef01997 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,3 @@ -**New Maintainer**: `Andrew Chen Wang`_ is a new maintainer of this repo. Bordage is still the admin but will most likely be inactive. - Django Cachalot =============== @@ -27,11 +25,7 @@ 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. - -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. +Cachalot officially supports Python 3.5-3.8 and Django 2.0-2.2, 3.0 with the databases PostgreSQL, SQLite, and MySQL. Third-Party Cache Comparison ---------------------------- diff --git a/benchmark.py b/benchmark.py index cbbaf8b..c240ee5 100755 --- a/benchmark.py +++ b/benchmark.py @@ -1,7 +1,3 @@ -#!/usr/bin/env python -# coding: utf-8 - -from __future__ import unicode_literals, print_function from collections import OrderedDict import io import os diff --git a/cachalot/api.py b/cachalot/api.py index 90df8a5..18110d1 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 b165063..a0ecea0 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 @@ from .settings import ( @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 3fd64dd..6acde16 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 77db96e..0ea2fd9 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.models.sql.compiler import ( ) 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 _patch_cursor(): 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 3a7033d..e9df548 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 2d0ac20..56892af 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/migrations/0001_initial.py b/cachalot/tests/migrations/0001_initial.py index 41f11fc..918cc3e 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 fe109c1..fbb0d9a 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 e98aaeb..e0cfd36 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 634b0f2..c89c6fd 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 44420f5..f9fc03b 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 4709c66..9385bc1 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 1ee5f0d..71e3911 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 7b3530d..9f21f41 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 @@ class TestUtilsMixin: 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 30dd2a9..cd7cd63 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 411aaa7..00d7d82 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 f3dff91..05c1b05 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 8e09c95..b8f7b28 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 f5c157d..7ab99be 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 import QuerySet, Subquery, Exists 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, bytes, str, 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/docs/index.rst b/docs/index.rst index 87ccaec..ae44035 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -21,7 +21,7 @@ Caches your Django ORM queries and automatically invalidates them. :target: https://scrutinizer-ci.com/g/noripyt/django-cachalot/ .. image:: https://img.shields.io/badge/cachalot-Chat%20on%20Slack-green?style=flat&logo=slack - :target: https://join.slack.com/t/cachalotdjango/shared_invite/enQtOTMyNzI0NTQzOTA3LWViYmYwMWY3MmU0OTZkYmNiMjBhN2NjNjc4OWVlZDNiMjMxN2Y3YzljYmNiYTY4ZTRjOGQxZDRiMTM0NWE3NGI + :target: https://join.slack.com/t/cachalotdjango/shared_invite/zt-dd0tj27b-cIH6VlaSOjAWnTG~II5~qw Usage ..... diff --git a/docs/quickstart.rst b/docs/quickstart.rst index fde8092..21946f4 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -4,15 +4,15 @@ Quick start Requirements ............ -- Django 1.11, 2.0-2.2, or 3.0 -- Python 2.7, 3.4-3.8 +- Django 2.0-2.2, or 3.0 +- Python 3.5-3.8 - a cache configured as ``'default'`` with one of these backends: - `django-redis `_ - - `memcached `_ + - `memcached `_ (using either python-memcached or pylibmc) - - `filebased `_ - - `locmem `_ + - `filebased `_ + - `locmem `_ (but it’s not shared between processes, see :ref:`locmem limits `) - one of these databases: diff --git a/docs/reporting.rst b/docs/reporting.rst index 4ea16e5..727cba5 100644 --- a/docs/reporting.rst +++ b/docs/reporting.rst @@ -7,7 +7,7 @@ Bug reports, questions, discussion, new features `on GitHub `_ - If you have **a question** on how django-cachalot works or to **simply discuss**, - `chat with us on Slack `_. + `chat with us on Slack `_. - If you want **to add a feature**: - if you have an idea on how to implement it, you can fork the project @@ -15,4 +15,4 @@ Bug reports, questions, discussion, new features someone else could already be working on it - if you’re sure that it’s a must-have feature, open an issue - if it’s just a vague idea, please - `ask on Slack `_ first + `ask on Slack `_ first diff --git a/requirements.txt b/requirements.txt index 37d10bc..82a39ab 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/setup.py b/setup.py index a730564..de9585a 100755 --- a/setup.py +++ b/setup.py @@ -26,16 +26,16 @@ setup( 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', - 'Framework :: Django :: 1.11', 'Framework :: Django :: 2.0', 'Framework :: Django :: 2.1', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', + 'Framework :: Django :: 2.2', + 'Framework :: Django :: 3.0', '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 :: Internet :: WWW/HTTP', ], license='BSD', diff --git a/tox.ini b/tox.ini index 239f434..dea18d0 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