From 37298a8cddde347c3f83fb911f44f233778272d8 Mon Sep 17 00:00:00 2001 From: Ivan Elfimov Date: Fri, 31 Jan 2020 16:17:54 +0300 Subject: [PATCH 1/5] Add django 3 support --- watson/backends.py | 5 ++--- watson/models.py | 3 +-- watson/views.py | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/watson/backends.py b/watson/backends.py index 30aceee..07b2504 100644 --- a/watson/backends.py +++ b/watson/backends.py @@ -11,7 +11,6 @@ from django.db import transaction, connections, router from django.db.models import Q, FloatField from django.db.models.expressions import RawSQL, Value from django.utils.encoding import force_text -from django.utils import six from watson.models import SearchEntry, has_int_pk @@ -43,7 +42,7 @@ def escape_query(text, re_escape_chars): return text -class SearchBackend(six.with_metaclass(abc.ABCMeta)): +class SearchBackend(metaclass=abc.ABCMeta): """Base class for all search backends.""" def is_installed(self): @@ -87,7 +86,7 @@ class SearchBackend(six.with_metaclass(abc.ABCMeta)): return connection.ops.quote_name(column_name) -class RegexSearchMixin(six.with_metaclass(abc.ABCMeta)): +class RegexSearchMixin(metaclass=abc.ABCMeta): """Mixin to adding regex search to a search backend.""" diff --git a/watson/models.py b/watson/models.py index f18cd8b..db881bb 100644 --- a/watson/models.py +++ b/watson/models.py @@ -6,7 +6,7 @@ import uuid from django.db import models from django.contrib.contenttypes.models import ContentType -from django.utils.encoding import python_2_unicode_compatible, force_text +from django.utils.encoding import force_text from django.utils.functional import cached_property try: @@ -42,7 +42,6 @@ def get_str_pk(obj, connection): META_CACHE_KEY = "_meta_cache" -@python_2_unicode_compatible class SearchEntry(models.Model): """An entry in the search index.""" diff --git a/watson/views.py b/watson/views.py index 1cf5e63..0c50c1b 100644 --- a/watson/views.py +++ b/watson/views.py @@ -6,7 +6,6 @@ import json from django.shortcuts import redirect from django.http import HttpResponse -from django.utils import six from django.views import generic from django.views.generic.list import BaseListView @@ -66,7 +65,7 @@ class SearchMixin(object): context = super(SearchMixin, self).get_context_data(**kwargs) context["query"] = self.query # Process extra context. - for key, value in six.iteritems(self.get_extra_context()): + for key, value in self.get_extra_context().items(): if callable(value): value = value() context[key] = value From 35796c3154249808ca72e98953fbb917f3c924ed Mon Sep 17 00:00:00 2001 From: Ivan Elfimov Date: Fri, 31 Jan 2020 16:41:04 +0300 Subject: [PATCH 2/5] change test matrix according to `etianen/django-reversion` --- .travis.yml | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 50eddfb..4847e68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,32 +4,25 @@ python: - 3.8 - 3.7 - 3.6 - - 3.5 - - 2.7 cache: pip env: global: - PYTHONWARNINGS=default,ignore::PendingDeprecationWarning,ignore::ResourceWarning + - DJANGO_DATABASE_USER_POSTGRES=postgres + - DJANGO_DATABASE_USER_MYSQL=travis matrix: + - DJANGO='>=3.0,<3.1' + - DJANGO='>=2.2,<3.0' - DJANGO='>=2.1,<2.2' - DJANGO='>=2.0,<2.1' - DJANGO='>=1.11,<1.12' - - DJANGO='>=1.10,<1.11' - - DJANGO='>=1.9,<1.10' - - DJANGO='>=1.8,<1.9' matrix: fast_finish: true exclude: - python: 3.8 - env: DJANGO='>=1.10,<1.11' - - python: 3.8 - env: DJANGO='>=1.9,<1.10' - - python: 3.8 - env: DJANGO='>=1.8,<1.9' - - python: 2.7 - env: DJANGO='>=2.0,<2.1' - - python: 2.7 - env: DJANGO='>=2.1,<2.2' + env: DJANGO='>=1.11,<1.12' + - python: 3.7 + env: DJANGO='>=1.11,<1.12' addons: apt: packages: @@ -56,7 +49,7 @@ deploy: secure: rzaq3pbJz25SVXyR/fn+gLaYxu0LqCEE+wcesg8pjA8cLLvFdLvXi0ZjmixxVl2u4HlndZrUgwTrRGVIQR1TOL0jGRYOUCJDzAaZqJkg+Qykz89iKSnentyOpNJe6fRAHsqFxBESYZjG8JEZvtRv+JIZLY+QR+KCA1xaeu4Afpw= on: tags: true - condition: $DJANGO = '>=2.0,<2.1' + condition: $DJANGO = '>=3.0,<3.1' python: 3.8 repo: etianen/django-watson notifications: From 918590bd067b4f6fa192099ae5cbdf444290eee6 Mon Sep 17 00:00:00 2001 From: Ivan Elfimov Date: Fri, 31 Jan 2020 16:49:56 +0300 Subject: [PATCH 3/5] remove python_2_unicode_compatible from tests --- tests/test_watson/models.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_watson/models.py b/tests/test_watson/models.py index 35f4386..9e7ba5b 100644 --- a/tests/test_watson/models.py +++ b/tests/test_watson/models.py @@ -1,9 +1,8 @@ import uuid from django.db import models -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text -@python_2_unicode_compatible class TestModelBase(models.Model): title = models.CharField( max_length=200, From fafda668699c116f617e41eecb78d48e53c417a8 Mon Sep 17 00:00:00 2001 From: Ivan Elfimov Date: Mon, 3 Feb 2020 15:39:52 +0300 Subject: [PATCH 4/5] remove unused variables from travis config --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4847e68..5284298 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,6 @@ cache: pip env: global: - PYTHONWARNINGS=default,ignore::PendingDeprecationWarning,ignore::ResourceWarning - - DJANGO_DATABASE_USER_POSTGRES=postgres - - DJANGO_DATABASE_USER_MYSQL=travis matrix: - DJANGO='>=3.0,<3.1' - DJANGO='>=2.2,<3.0' From a2e0844664a15805935fbb5287050d3cadff6148 Mon Sep 17 00:00:00 2001 From: biozz Date: Mon, 3 Feb 2020 20:25:38 +0300 Subject: [PATCH 5/5] bump python and django versions --- README.markdown | 2 +- setup.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index b891f81..8702086 100644 --- a/README.markdown +++ b/README.markdown @@ -17,7 +17,7 @@ Features * Order results by relevance. * No need to install additional third-party modules or services. * Fast and scaleable enough for most use cases. -* Supports Django 1.8+, Python 2.7+. +* Supports Django 1.11+, Python 3.6+. Documentation diff --git a/setup.py b/setup.py index cba7447..aa9ea1d 100644 --- a/setup.py +++ b/setup.py @@ -33,8 +33,6 @@ setup( "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8',