diff --git a/.drone.yml b/.drone.yml index 513bd3a..0a42de2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,6 +17,17 @@ steps: depends_on: - clone +- name: coverage + image: plugins/codecov + settings: + token: + from_secret: codecov_token + files: + - '*.xml' + required: true + depends_on: + - python3.8 + - name: python3.7 image: python:3.7 commands: @@ -33,22 +44,6 @@ steps: depends_on: - clone -- name: python2.7 - image: python:2.7 - commands: - - pip install tox - - tox -e $(tox -l | grep py27 | paste -sd ",") - depends_on: - - clone - -- name: pypy - image: pypy:2.7 - commands: - - pip install tox - - tox -e $(tox -l | grep pypy- | paste -sd ",") - depends_on: - - clone - - name: pypy3 image: pypy:3.6 commands: @@ -61,17 +56,6 @@ steps: depends_on: - clone -- name: coverage - image: plugins/codecov - settings: - token: - from_secret: codecov_token - files: - - '*.xml' - required: true - depends_on: - - python3.8 - trigger: trigger: ref: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f6cbf7b..35fb72e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,11 +19,14 @@ repos: args: [--allow-multiple-documents] - id: debug-statements - id: end-of-file-fixer - - id: fix-encoding-pragma - - id: flake8 - id: mixed-line-ending - id: trailing-whitespace + - repo: https://gitlab.com/pycqa/flake8 + rev: 'master' + hooks: + - id: flake8 + - repo: https://github.com/miki725/importanize rev: 'master' hooks: @@ -31,10 +34,10 @@ repos: language_version: python3 - repo: https://github.com/python/black - rev: 'master' + rev: 'stable' hooks: - id: black - args: [--line-length=88, --safe] + args: [--line-length=88, --safe, --check, --diff] language_version: python3 exclude: test_data/.*$ diff --git a/.travis.yml b/.travis.yml index 7ca23a0..c3f016c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,8 @@ addons: language: python python: - - "3.6-dev" - - "3.7-dev" - - "2.7" + - "3.6" + - "3.7" - "pypy" - "pypy3.5-7.0" diff --git a/docs/conf.py b/docs/conf.py index 9678a00..c44351f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # # This file is execfile()d with the current directory set to its # containing dir. diff --git a/manage.py b/manage.py index d4f0ee8..307d211 100755 --- a/manage.py +++ b/manage.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import os import sys diff --git a/requirements.txt b/requirements.txt index 3507dae..5b0f7a9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ cached-property -Django>=1.8 +Django>=2.2 enum-compat -six diff --git a/setup.py b/setup.py index 04e153a..32e4cac 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- -from __future__ import print_function import os from setuptools import find_packages, setup @@ -41,10 +39,10 @@ def read(fname): "Intended Audience :: Developers", "Natural Language :: English", "License :: OSI Approved :: MIT License", - "Programming Language :: Python", - "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", "Development Status :: 2 - Pre-Alpha", ], ) diff --git a/test_project/__init__.py b/test_project/__init__.py index 8f4a3fc..e69de29 100644 --- a/test_project/__init__.py +++ b/test_project/__init__.py @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals diff --git a/test_project/alchemy.py b/test_project/alchemy.py index a3f54e9..00ea8e1 100644 --- a/test_project/alchemy.py +++ b/test_project/alchemy.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from sqlalchemy.ext.declarative import declarative_base diff --git a/test_project/generic/__init__.py b/test_project/generic/__init__.py index ba25ec7..e69de29 100644 --- a/test_project/generic/__init__.py +++ b/test_project/generic/__init__.py @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals diff --git a/test_project/generic/api.py b/test_project/generic/api.py index 4d79b63..700a57e 100644 --- a/test_project/generic/api.py +++ b/test_project/generic/api.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from rest_framework import serializers from rest_framework.viewsets import ModelViewSet diff --git a/test_project/generic/models.py b/test_project/generic/models.py index 6227ed0..6d0bcba 100644 --- a/test_project/generic/models.py +++ b/test_project/generic/models.py @@ -1,13 +1,8 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - -import six from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models -@six.python_2_unicode_compatible class ModelA(models.Model): name = models.CharField(max_length=64) @@ -15,7 +10,6 @@ def __str__(self): return self.name -@six.python_2_unicode_compatible class ModelB(models.Model): name = models.CharField(max_length=64) a = models.ForeignKey( diff --git a/test_project/many_to_many/alchemy.py b/test_project/many_to_many/alchemy.py index e3f6b28..3b6c6e9 100644 --- a/test_project/many_to_many/alchemy.py +++ b/test_project/many_to_many/alchemy.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from sqlalchemy import Column, Integer, String from sqlalchemy.orm import backref, relationship from sqlalchemy.schema import ForeignKey, Table diff --git a/test_project/many_to_many/api.py b/test_project/many_to_many/api.py index 4faa4ae..35c7679 100644 --- a/test_project/many_to_many/api.py +++ b/test_project/many_to_many/api.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import ReadOnlyModelViewSet diff --git a/test_project/many_to_many/models.py b/test_project/many_to_many/models.py index c759368..fcaf53f 100644 --- a/test_project/many_to_many/models.py +++ b/test_project/many_to_many/models.py @@ -1,11 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - -import six from django.db import models -@six.python_2_unicode_compatible class Publication(models.Model): title = models.CharField(max_length=30) @@ -16,7 +11,6 @@ class Meta: ordering = ("title",) -@six.python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) publications = models.ManyToManyField(Publication, related_name="articles") diff --git a/test_project/many_to_one/alchemy.py b/test_project/many_to_one/alchemy.py index 381fcfc..563f202 100644 --- a/test_project/many_to_one/alchemy.py +++ b/test_project/many_to_one/alchemy.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from sqlalchemy import Column, Date, Integer, String from sqlalchemy.orm import backref, relationship diff --git a/test_project/many_to_one/api.py b/test_project/many_to_one/api.py index c02df33..96c4b19 100644 --- a/test_project/many_to_one/api.py +++ b/test_project/many_to_one/api.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import ReadOnlyModelViewSet diff --git a/test_project/many_to_one/models.py b/test_project/many_to_one/models.py index 398422e..65fb93c 100644 --- a/test_project/many_to_one/models.py +++ b/test_project/many_to_one/models.py @@ -1,11 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - -import six from django.db import models -@six.python_2_unicode_compatible class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) @@ -15,7 +10,6 @@ def __str__(self): return "%s %s" % (self.first_name, self.last_name) -@six.python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateField() diff --git a/test_project/middleware.py b/test_project/middleware.py index 8a67928..6a57ec2 100644 --- a/test_project/middleware.py +++ b/test_project/middleware.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - from django.conf import settings from sqlalchemy.orm import sessionmaker diff --git a/test_project/one_to_one/alchemy.py b/test_project/one_to_one/alchemy.py index ebc6893..693049b 100644 --- a/test_project/one_to_one/alchemy.py +++ b/test_project/one_to_one/alchemy.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from sqlalchemy import Boolean, Column, Integer, String from sqlalchemy.orm import backref, relationship diff --git a/test_project/one_to_one/api.py b/test_project/one_to_one/api.py index 2f5cf91..26a271d 100644 --- a/test_project/one_to_one/api.py +++ b/test_project/one_to_one/api.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals import operator from django import forms diff --git a/test_project/one_to_one/models.py b/test_project/one_to_one/models.py index 8cd89fc..c51ddf8 100644 --- a/test_project/one_to_one/models.py +++ b/test_project/one_to_one/models.py @@ -1,11 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - -import six from django.db import models -@six.python_2_unicode_compatible class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) @@ -14,7 +9,6 @@ def __str__(self): return "%s the place" % self.name -@six.python_2_unicode_compatible class Restaurant(models.Model): place = models.OneToOneField(Place, primary_key=True, on_delete=models.CASCADE) serves_hot_dogs = models.BooleanField(default=False) @@ -24,7 +18,6 @@ def __str__(self): return "%s the restaurant" % self.place.name -@six.python_2_unicode_compatible class Waiter(models.Model): restaurant = models.ForeignKey(Restaurant, on_delete=models.CASCADE) name = models.CharField(max_length=50) diff --git a/test_project/settings.py b/test_project/settings.py index 6539748..e560229 100644 --- a/test_project/settings.py +++ b/test_project/settings.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Bare ``settings.py`` for running tests for url_filter import os diff --git a/test_project/urls.py b/test_project/urls.py index 0e4280f..9853eac 100644 --- a/test_project/urls.py +++ b/test_project/urls.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - import debug_toolbar from django.conf import settings from django.conf.urls import url diff --git a/tests/__init__.py b/tests/__init__.py index 8f4a3fc..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals diff --git a/tests/backends/__init__.py b/tests/backends/__init__.py index ba25ec7..e69de29 100644 --- a/tests/backends/__init__.py +++ b/tests/backends/__init__.py @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals diff --git a/tests/backends/test_django.py b/tests/backends/test_django.py index 3c68ace..a3397ce 100644 --- a/tests/backends/test_django.py +++ b/tests/backends/test_django.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - import mock from test_project.one_to_one.models import Place diff --git a/tests/backends/test_plain.py b/tests/backends/test_plain.py index ef29dec..f06fd9d 100644 --- a/tests/backends/test_plain.py +++ b/tests/backends/test_plain.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals from datetime import datetime from url_filter.backends.plain import PlainFilterBackend diff --git a/tests/backends/test_sqlalchemy.py b/tests/backends/test_sqlalchemy.py index 65a6a39..4c64a84 100644 --- a/tests/backends/test_sqlalchemy.py +++ b/tests/backends/test_sqlalchemy.py @@ -1,8 +1,4 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - import pytest -import six from alchemy_mock.comparison import ExpressionMatcher from sqlalchemy import func from sqlalchemy.orm import joinedload @@ -34,7 +30,7 @@ def test_empty(self, alchemy_db): alchemy_db.query(Place), context={"context": "here"} ) - assert "WHERE 0 = 1" in six.text_type(backend.empty()) + assert "WHERE 0 = 1" in str(backend.empty()) def test_get_model(self, alchemy_db): backend = SQLAlchemyFilterBackend(alchemy_db.query(Place)) @@ -57,7 +53,7 @@ def test_filter(self, alchemy_db): filtered = backend.filter() - sql = six.text_type(filtered) + sql = str(filtered) # eagerloads via outerjoin assert "LEFT OUTER JOIN one_to_one_restaurant" not in sql assert "LEFT OUTER JOIN one_to_one_waiter" not in sql @@ -77,7 +73,7 @@ def test_filter_already_selectinload(self, alchemy_db): filtered = backend.filter() - sql = six.text_type(filtered) + sql = str(filtered) # eagerloads via outerjoin assert "LEFT OUTER JOIN one_to_one_restaurant" in sql assert "LEFT OUTER JOIN one_to_one_waiter" not in sql @@ -97,7 +93,7 @@ def test_filter_already_eagerloaded(self, alchemy_db): filtered = backend.filter() - sql = six.text_type(filtered) + sql = str(filtered) # eagerloads via outerjoin assert "LEFT OUTER JOIN one_to_one_restaurant" in sql assert "LEFT OUTER JOIN one_to_one_waiter" in sql diff --git a/tests/conftest.py b/tests/conftest.py index 53688be..f8146d9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - import pytest from django.conf import settings from django.core.management import call_command diff --git a/tests/filtersets/__init__.py b/tests/filtersets/__init__.py index 8f4a3fc..e69de29 100644 --- a/tests/filtersets/__init__.py +++ b/tests/filtersets/__init__.py @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals diff --git a/tests/filtersets/test_base.py b/tests/filtersets/test_base.py index cc3d772..f4d7e04 100644 --- a/tests/filtersets/test_base.py +++ b/tests/filtersets/test_base.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - import pytest from django import forms from django.http import QueryDict diff --git a/tests/filtersets/test_django.py b/tests/filtersets/test_django.py index 07761f7..2a158fd 100644 --- a/tests/filtersets/test_django.py +++ b/tests/filtersets/test_django.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - import pytest from django import forms from django.db import models diff --git a/tests/filtersets/test_plain.py b/tests/filtersets/test_plain.py index b33b7d4..0c296d8 100644 --- a/tests/filtersets/test_plain.py +++ b/tests/filtersets/test_plain.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - from django import forms from url_filter.filters import Filter diff --git a/tests/filtersets/test_sqlalchemy.py b/tests/filtersets/test_sqlalchemy.py index b35c19c..d505310 100644 --- a/tests/filtersets/test_sqlalchemy.py +++ b/tests/filtersets/test_sqlalchemy.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - import pytest from django import forms from sqlalchemy.orm.properties import ColumnProperty diff --git a/tests/integrations/__init__.py b/tests/integrations/__init__.py index 8f4a3fc..e69de29 100644 --- a/tests/integrations/__init__.py +++ b/tests/integrations/__init__.py @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals diff --git a/tests/integrations/test_drf.py b/tests/integrations/test_drf.py index 9d474aa..b8872ee 100644 --- a/tests/integrations/test_drf.py +++ b/tests/integrations/test_drf.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - import mock import pytest from django.core.exceptions import ValidationError as DjangoValidationError diff --git a/tests/integrations/test_drf_coreapi.py b/tests/integrations/test_drf_coreapi.py index 3e26869..93dcc1b 100644 --- a/tests/integrations/test_drf_coreapi.py +++ b/tests/integrations/test_drf_coreapi.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from rest_framework.viewsets import ModelViewSet from test_project.one_to_one.models import Restaurant diff --git a/tests/test_fields.py b/tests/test_fields.py index 5c842f9..d0a03ab 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - import pytest from django import forms diff --git a/tests/test_filters.py b/tests/test_filters.py index b76edaf..5457d66 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals from functools import partial import mock diff --git a/tests/test_utils.py b/tests/test_utils.py index 5120f29..d910434 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - from url_filter.utils import FilterSpec, LookupConfig, SubClassDict, dictify diff --git a/tox.ini b/tox.ini index c01a164..70acd81 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,15 @@ [tox] envlist = - {py27,py36,py37,py38,pypy,pypy3}-django{18,11} - {py36,py37,py38,pypy3}-django{20,latest} + {py35,py36,py37,pypy3}-django22 + {py36,py37,py38,pypy3}-django30 + {py36,py37,py38,pypy3}-djangolatest [testenv] basepython = - py27: python2.7 + py35: python3.5 py36: python3.6 py37: python3.7 py38: python3.8 - pypy: pypy pypy3: pypy3 passenv = * setenv = @@ -18,11 +18,8 @@ commands = make install INSTALL_LOG=/dev/null make clean-build clean-pyc clean-test test deps = - django18: django<1.9 - django18: djangorestframework<3.7 - django18: django-debug-toolbar<1.10 - django11: django<2 - django20: django<2.1 + django22: django==2.2 + django30: django==3.0 djangolatest: django whitelist_externals = make diff --git a/url_filter/__init__.py b/url_filter/__init__.py index d47e8c8..783a9ba 100644 --- a/url_filter/__init__.py +++ b/url_filter/__init__.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - - __author__ = "Miroslav Shubernetskiy" __email__ = "miroslav@miki725.com" __version__ = "0.3.15" diff --git a/url_filter/backends/__init__.py b/url_filter/backends/__init__.py index ba25ec7..e69de29 100644 --- a/url_filter/backends/__init__.py +++ b/url_filter/backends/__init__.py @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals diff --git a/url_filter/backends/base.py b/url_filter/backends/base.py index e9edba8..5499f8c 100644 --- a/url_filter/backends/base.py +++ b/url_filter/backends/base.py @@ -1,12 +1,9 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import abc -import six from cached_property import cached_property -class BaseFilterBackend(six.with_metaclass(abc.ABCMeta, object)): +class BaseFilterBackend(metaclass=abc.ABCMeta): """ Base filter backend from which all other backends must subclass. diff --git a/url_filter/backends/django.py b/url_filter/backends/django.py index 48aa2c3..a559ff8 100644 --- a/url_filter/backends/django.py +++ b/url_filter/backends/django.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from django.core.exceptions import FieldDoesNotExist from django.db.models.constants import LOOKUP_SEP diff --git a/url_filter/backends/plain.py b/url_filter/backends/plain.py index f2cb8e7..31e7dcc 100644 --- a/url_filter/backends/plain.py +++ b/url_filter/backends/plain.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import re from ..utils import dictify diff --git a/url_filter/backends/sqlalchemy.py b/url_filter/backends/sqlalchemy.py index 9c88015..28d7015 100644 --- a/url_filter/backends/sqlalchemy.py +++ b/url_filter/backends/sqlalchemy.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import itertools from sqlalchemy import false, func diff --git a/url_filter/constants.py b/url_filter/constants.py index 6f820c4..b4c651b 100644 --- a/url_filter/constants.py +++ b/url_filter/constants.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import enum diff --git a/url_filter/exceptions.py b/url_filter/exceptions.py index 52c72a6..cb07850 100644 --- a/url_filter/exceptions.py +++ b/url_filter/exceptions.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - - class SkipFilter(Exception): """ Exception to be used when any particular filter diff --git a/url_filter/fields.py b/url_filter/fields.py index 04f6d37..36d52a6 100644 --- a/url_filter/fields.py +++ b/url_filter/fields.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from django import forms from .validators import MaxLengthValidator, MinLengthValidator diff --git a/url_filter/filters.py b/url_filter/filters.py index 8b826df..a44dd57 100644 --- a/url_filter/filters.py +++ b/url_filter/filters.py @@ -1,10 +1,7 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import abc import re from functools import wraps -import six from cached_property import cached_property from django import forms from django.core.exceptions import ValidationError @@ -40,7 +37,7 @@ ) -class BaseFilter(six.with_metaclass(abc.ABCMeta, object)): +class BaseFilter(metaclass=abc.ABCMeta): """ Base class to be used for defining both filters and filtersets. @@ -75,9 +72,7 @@ def __init__(self, source=None, *args, **kwargs): self.is_bound = False def __repr__(self): - data = self.repr() - data = data if six.PY3 else data.encode("utf-8") - return data + return self.repr() @abc.abstractmethod def repr(self, prefix=""): diff --git a/url_filter/filtersets/__init__.py b/url_filter/filtersets/__init__.py index 2a81d10..9b8851e 100644 --- a/url_filter/filtersets/__init__.py +++ b/url_filter/filtersets/__init__.py @@ -1,5 +1,2 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from .base import * # noqa from .django import * # noqa diff --git a/url_filter/filtersets/base.py b/url_filter/filtersets/base.py index d9ca0e5..7ed5579 100644 --- a/url_filter/filtersets/base.py +++ b/url_filter/filtersets/base.py @@ -1,11 +1,9 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import abc +import functools import re from collections import defaultdict from copy import deepcopy -import six from cached_property import cached_property from django.core.exceptions import ValidationError from django.core.validators import RegexValidator @@ -90,7 +88,7 @@ def __new__(cls, name, bases, attrs): return new_class -class FilterSet(six.with_metaclass(FilterSetMeta, BaseFilter)): +class FilterSet(BaseFilter, metaclass=FilterSetMeta): """ Main user-facing classes to use filtersets. @@ -397,7 +395,7 @@ def _generate_lookup_configs(self): for value in values: yield LookupConfig( key, - six.moves.reduce( + functools.reduce( lambda a, b: {b: a}, (key.replace("!", "").split(LOOKUP_SEP) + [value])[::-1], ), diff --git a/url_filter/filtersets/django.py b/url_filter/filtersets/django.py index 7eb31b0..776f06b 100644 --- a/url_filter/filtersets/django.py +++ b/url_filter/filtersets/django.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import operator from django import forms diff --git a/url_filter/filtersets/plain.py b/url_filter/filtersets/plain.py index 8e5e85d..c2ce2de 100644 --- a/url_filter/filtersets/plain.py +++ b/url_filter/filtersets/plain.py @@ -1,9 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals from datetime import date, datetime, time from decimal import Decimal -import six from django import forms from ..backends.plain import PlainFilterBackend @@ -15,8 +12,8 @@ DATA_TYPES_MAPPING = SubClassDict( { - six.string_types: forms.CharField(), - six.integer_types: forms.IntegerField(), + str: forms.CharField(), + int: forms.IntegerField(), bool: forms.BooleanField(required=False), float: forms.FloatField(), Decimal: forms.DecimalField(), diff --git a/url_filter/filtersets/sqlalchemy.py b/url_filter/filtersets/sqlalchemy.py index 8ca6a79..bfefcfe 100644 --- a/url_filter/filtersets/sqlalchemy.py +++ b/url_filter/filtersets/sqlalchemy.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import inspect from functools import partial diff --git a/url_filter/integrations/drf.py b/url_filter/integrations/drf.py index d5e2705..7d578c1 100644 --- a/url_filter/integrations/drf.py +++ b/url_filter/integrations/drf.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from django.core.exceptions import ValidationError as DjangoValidationError from rest_framework.exceptions import ValidationError from rest_framework.filters import BaseFilterBackend diff --git a/url_filter/integrations/drf_coreapi.py b/url_filter/integrations/drf_coreapi.py index 3309047..3881f60 100644 --- a/url_filter/integrations/drf_coreapi.py +++ b/url_filter/integrations/drf_coreapi.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - import coreapi import coreschema from django import forms diff --git a/url_filter/utils.py b/url_filter/utils.py index 4cbd764..914864d 100644 --- a/url_filter/utils.py +++ b/url_filter/utils.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import inspect from contextlib import contextmanager diff --git a/url_filter/validators.py b/url_filter/validators.py index d40d0ca..0c6536f 100644 --- a/url_filter/validators.py +++ b/url_filter/validators.py @@ -1,12 +1,9 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from django.core.validators import ( MaxLengthValidator as _MaxLengthValidator, MinLengthValidator as _MinLengthValidator, ) from django.utils.deconstruct import deconstructible -from django.utils.translation import ungettext_lazy +from django.utils.translation import ngettext_lazy @deconstructible @@ -16,7 +13,7 @@ class MinLengthValidator(_MinLengthValidator): """ code = "min_length" - message = ungettext_lazy( + message = ngettext_lazy( "Ensure this value has at least %(limit_value)d items (it has %(show_value)d).", "Ensure this value has at least %(limit_value)d items (it has %(show_value)d).", "limit_value", @@ -36,7 +33,7 @@ class MaxLengthValidator(_MaxLengthValidator): """ code = "max_length" - message = ungettext_lazy( + message = ngettext_lazy( "Ensure this value has at most %(limit_value)d items (it has %(show_value)d).", "Ensure this value has at most %(limit_value)d items (it has %(show_value)d).", "limit_value",