From f5e7bb3a7c04d6ff78ce1779a77dbee2ef016dd6 Mon Sep 17 00:00:00 2001 From: Bastien Vallet Date: Fri, 15 May 2020 17:14:41 +0200 Subject: [PATCH 1/8] Remove python 2.x support --- .drone.yml | 16 ---------------- .travis.yml | 5 ++--- setup.py | 6 +++--- tox.ini | 4 +--- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/.drone.yml b/.drone.yml index 513bd3a..d55a4b3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,22 +33,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: 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/setup.py b/setup.py index 04e153a..54b39f3 100644 --- a/setup.py +++ b/setup.py @@ -41,10 +41,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/tox.ini b/tox.ini index c01a164..19bb2e7 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,13 @@ [tox] envlist = - {py27,py36,py37,py38,pypy,pypy3}-django{18,11} + {py36,py37,py38,pypy3}-django{18,11} {py36,py37,py38,pypy3}-django{20,latest} [testenv] basepython = - py27: python2.7 py36: python3.6 py37: python3.7 py38: python3.8 - pypy: pypy pypy3: pypy3 passenv = * setenv = From 60c50addf5e4dc429470dd0b58abd41692e699d6 Mon Sep 17 00:00:00 2001 From: Bastien Vallet Date: Mon, 18 May 2020 11:01:56 +0200 Subject: [PATCH 2/8] [cleanup] Remove python2 old stuff --- setup.py | 1 - test_project/__init__.py | 1 - test_project/alchemy.py | 2 -- test_project/generic/__init__.py | 1 - test_project/generic/api.py | 2 -- test_project/generic/models.py | 2 -- test_project/many_to_many/alchemy.py | 2 -- test_project/many_to_many/api.py | 2 -- test_project/many_to_many/models.py | 2 -- test_project/many_to_one/alchemy.py | 2 -- test_project/many_to_one/api.py | 2 -- test_project/many_to_one/models.py | 2 -- test_project/middleware.py | 2 -- test_project/one_to_one/alchemy.py | 2 -- test_project/one_to_one/api.py | 1 - test_project/one_to_one/models.py | 2 -- test_project/urls.py | 2 -- tests/__init__.py | 1 - tests/backends/__init__.py | 1 - tests/backends/test_django.py | 2 -- tests/backends/test_plain.py | 1 - tests/backends/test_sqlalchemy.py | 2 -- tests/conftest.py | 2 -- tests/filtersets/__init__.py | 1 - tests/filtersets/test_base.py | 2 -- tests/filtersets/test_django.py | 2 -- tests/filtersets/test_plain.py | 2 -- tests/filtersets/test_sqlalchemy.py | 2 -- tests/integrations/__init__.py | 1 - tests/integrations/test_drf.py | 2 -- tests/integrations/test_drf_coreapi.py | 2 -- tests/test_fields.py | 2 -- tests/test_filters.py | 1 - tests/test_utils.py | 2 -- url_filter/__init__.py | 3 --- url_filter/backends/__init__.py | 1 - url_filter/backends/base.py | 1 - url_filter/backends/django.py | 2 -- url_filter/backends/plain.py | 1 - url_filter/backends/sqlalchemy.py | 1 - url_filter/constants.py | 1 - url_filter/exceptions.py | 3 --- url_filter/fields.py | 2 -- url_filter/filters.py | 1 - url_filter/filtersets/__init__.py | 2 -- url_filter/filtersets/base.py | 1 - url_filter/filtersets/django.py | 1 - url_filter/filtersets/plain.py | 1 - url_filter/filtersets/sqlalchemy.py | 1 - url_filter/integrations/drf.py | 2 -- url_filter/integrations/drf_coreapi.py | 2 -- url_filter/utils.py | 1 - url_filter/validators.py | 2 -- 53 files changed, 87 deletions(-) diff --git a/setup.py b/setup.py index 54b39f3..9d83d38 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import print_function import os from setuptools import find_packages, setup diff --git a/test_project/__init__.py b/test_project/__init__.py index 8f4a3fc..40a96af 100644 --- a/test_project/__init__.py +++ b/test_project/__init__.py @@ -1,2 +1 @@ # -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals diff --git a/test_project/alchemy.py b/test_project/alchemy.py index a3f54e9..90a43ab 100644 --- a/test_project/alchemy.py +++ b/test_project/alchemy.py @@ -1,6 +1,4 @@ # -*- 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..40a96af 100644 --- a/test_project/generic/__init__.py +++ b/test_project/generic/__init__.py @@ -1,2 +1 @@ # -*- 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..6c37852 100644 --- a/test_project/generic/api.py +++ b/test_project/generic/api.py @@ -1,6 +1,4 @@ # -*- 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..2d33357 100644 --- a/test_project/generic/models.py +++ b/test_project/generic/models.py @@ -1,6 +1,4 @@ # -*- 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 diff --git a/test_project/many_to_many/alchemy.py b/test_project/many_to_many/alchemy.py index e3f6b28..88a57d8 100644 --- a/test_project/many_to_many/alchemy.py +++ b/test_project/many_to_many/alchemy.py @@ -1,6 +1,4 @@ # -*- 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..b4dc3c5 100644 --- a/test_project/many_to_many/api.py +++ b/test_project/many_to_many/api.py @@ -1,6 +1,4 @@ # -*- 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..f536e99 100644 --- a/test_project/many_to_many/models.py +++ b/test_project/many_to_many/models.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - import six from django.db import models diff --git a/test_project/many_to_one/alchemy.py b/test_project/many_to_one/alchemy.py index 381fcfc..2f9d9ab 100644 --- a/test_project/many_to_one/alchemy.py +++ b/test_project/many_to_one/alchemy.py @@ -1,6 +1,4 @@ # -*- 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..f706e05 100644 --- a/test_project/many_to_one/api.py +++ b/test_project/many_to_one/api.py @@ -1,6 +1,4 @@ # -*- 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..b7b500a 100644 --- a/test_project/many_to_one/models.py +++ b/test_project/many_to_one/models.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - import six from django.db import models diff --git a/test_project/middleware.py b/test_project/middleware.py index 8a67928..d67e29a 100644 --- a/test_project/middleware.py +++ b/test_project/middleware.py @@ -1,6 +1,4 @@ # -*- 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..f087d69 100644 --- a/test_project/one_to_one/alchemy.py +++ b/test_project/one_to_one/alchemy.py @@ -1,6 +1,4 @@ # -*- 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..89a8093 100644 --- a/test_project/one_to_one/api.py +++ b/test_project/one_to_one/api.py @@ -1,5 +1,4 @@ # -*- 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..8a46846 100644 --- a/test_project/one_to_one/models.py +++ b/test_project/one_to_one/models.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - import six from django.db import models diff --git a/test_project/urls.py b/test_project/urls.py index 0e4280f..acce3bc 100644 --- a/test_project/urls.py +++ b/test_project/urls.py @@ -1,6 +1,4 @@ # -*- 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..40a96af 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,2 +1 @@ # -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals diff --git a/tests/backends/__init__.py b/tests/backends/__init__.py index ba25ec7..40a96af 100644 --- a/tests/backends/__init__.py +++ b/tests/backends/__init__.py @@ -1,2 +1 @@ # -*- 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..ffb1004 100644 --- a/tests/backends/test_django.py +++ b/tests/backends/test_django.py @@ -1,6 +1,4 @@ # -*- 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..e8aec32 100644 --- a/tests/backends/test_plain.py +++ b/tests/backends/test_plain.py @@ -1,5 +1,4 @@ # -*- 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..72b093f 100644 --- a/tests/backends/test_sqlalchemy.py +++ b/tests/backends/test_sqlalchemy.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - import pytest import six from alchemy_mock.comparison import ExpressionMatcher diff --git a/tests/conftest.py b/tests/conftest.py index 53688be..1c0f080 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,4 @@ # -*- 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..40a96af 100644 --- a/tests/filtersets/__init__.py +++ b/tests/filtersets/__init__.py @@ -1,2 +1 @@ # -*- 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..0015cc6 100644 --- a/tests/filtersets/test_base.py +++ b/tests/filtersets/test_base.py @@ -1,6 +1,4 @@ # -*- 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..b60d8cb 100644 --- a/tests/filtersets/test_django.py +++ b/tests/filtersets/test_django.py @@ -1,6 +1,4 @@ # -*- 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..8ae9a40 100644 --- a/tests/filtersets/test_plain.py +++ b/tests/filtersets/test_plain.py @@ -1,6 +1,4 @@ # -*- 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..a63f0bc 100644 --- a/tests/filtersets/test_sqlalchemy.py +++ b/tests/filtersets/test_sqlalchemy.py @@ -1,6 +1,4 @@ # -*- 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..40a96af 100644 --- a/tests/integrations/__init__.py +++ b/tests/integrations/__init__.py @@ -1,2 +1 @@ # -*- 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..b8f4e79 100644 --- a/tests/integrations/test_drf.py +++ b/tests/integrations/test_drf.py @@ -1,6 +1,4 @@ # -*- 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..b071d8e 100644 --- a/tests/integrations/test_drf_coreapi.py +++ b/tests/integrations/test_drf_coreapi.py @@ -1,6 +1,4 @@ # -*- 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..5d8891b 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1,6 +1,4 @@ # -*- 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..9a30284 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1,5 +1,4 @@ # -*- 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..d2578dd 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import print_function, unicode_literals - from url_filter.utils import FilterSpec, LookupConfig, SubClassDict, dictify diff --git a/url_filter/__init__.py b/url_filter/__init__.py index d47e8c8..eb1a0f7 100644 --- a/url_filter/__init__.py +++ b/url_filter/__init__.py @@ -1,7 +1,4 @@ # -*- 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..40a96af 100644 --- a/url_filter/backends/__init__.py +++ b/url_filter/backends/__init__.py @@ -1,2 +1 @@ # -*- 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..735e8cd 100644 --- a/url_filter/backends/base.py +++ b/url_filter/backends/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import abc import six diff --git a/url_filter/backends/django.py b/url_filter/backends/django.py index 48aa2c3..ca5a13c 100644 --- a/url_filter/backends/django.py +++ b/url_filter/backends/django.py @@ -1,6 +1,4 @@ # -*- 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..8ef979a 100644 --- a/url_filter/backends/plain.py +++ b/url_filter/backends/plain.py @@ -1,5 +1,4 @@ # -*- 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..8feca36 100644 --- a/url_filter/backends/sqlalchemy.py +++ b/url_filter/backends/sqlalchemy.py @@ -1,5 +1,4 @@ # -*- 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..0a8c71a 100644 --- a/url_filter/constants.py +++ b/url_filter/constants.py @@ -1,5 +1,4 @@ # -*- 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..b1a621c 100644 --- a/url_filter/exceptions.py +++ b/url_filter/exceptions.py @@ -1,7 +1,4 @@ # -*- 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..f448688 100644 --- a/url_filter/fields.py +++ b/url_filter/fields.py @@ -1,6 +1,4 @@ # -*- 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..cc66297 100644 --- a/url_filter/filters.py +++ b/url_filter/filters.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import abc import re from functools import wraps diff --git a/url_filter/filtersets/__init__.py b/url_filter/filtersets/__init__.py index 2a81d10..5a7bae4 100644 --- a/url_filter/filtersets/__init__.py +++ b/url_filter/filtersets/__init__.py @@ -1,5 +1,3 @@ # -*- 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..6bc9af1 100644 --- a/url_filter/filtersets/base.py +++ b/url_filter/filtersets/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals import abc import re from collections import defaultdict diff --git a/url_filter/filtersets/django.py b/url_filter/filtersets/django.py index 7eb31b0..3158ed8 100644 --- a/url_filter/filtersets/django.py +++ b/url_filter/filtersets/django.py @@ -1,5 +1,4 @@ # -*- 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..c221b99 100644 --- a/url_filter/filtersets/plain.py +++ b/url_filter/filtersets/plain.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals from datetime import date, datetime, time from decimal import Decimal diff --git a/url_filter/filtersets/sqlalchemy.py b/url_filter/filtersets/sqlalchemy.py index 8ca6a79..b18668f 100644 --- a/url_filter/filtersets/sqlalchemy.py +++ b/url_filter/filtersets/sqlalchemy.py @@ -1,5 +1,4 @@ # -*- 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..d6911f0 100644 --- a/url_filter/integrations/drf.py +++ b/url_filter/integrations/drf.py @@ -1,6 +1,4 @@ # -*- 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..8c06a18 100644 --- a/url_filter/integrations/drf_coreapi.py +++ b/url_filter/integrations/drf_coreapi.py @@ -1,6 +1,4 @@ # -*- 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..1bc8aa2 100644 --- a/url_filter/utils.py +++ b/url_filter/utils.py @@ -1,5 +1,4 @@ # -*- 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..296133b 100644 --- a/url_filter/validators.py +++ b/url_filter/validators.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals - from django.core.validators import ( MaxLengthValidator as _MaxLengthValidator, MinLengthValidator as _MinLengthValidator, From debbd3215e6ff0fc1606973d18c80b03a3b9712f Mon Sep 17 00:00:00 2001 From: Bastien Vallet Date: Mon, 18 May 2020 11:12:25 +0200 Subject: [PATCH 3/8] [CI] Only test against django supported version --- tox.ini | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tox.ini b/tox.ini index 19bb2e7..70acd81 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,12 @@ [tox] envlist = - {py36,py37,py38,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 = + py35: python3.5 py36: python3.6 py37: python3.7 py38: python3.8 @@ -16,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 From 3eb2770b4b3cb0fabf5986efa1792232381e4f00 Mon Sep 17 00:00:00 2001 From: Bastien Vallet Date: Mon, 18 May 2020 11:31:21 +0200 Subject: [PATCH 4/8] Fix deprecation warnings url_filter/validators.py:22: RemovedInDjango40Warning: django.utils.translation.ungettext_lazy() is deprecated in favor of django.utils.translation.ngettext_lazy(). --- url_filter/validators.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/url_filter/validators.py b/url_filter/validators.py index 296133b..70c746c 100644 --- a/url_filter/validators.py +++ b/url_filter/validators.py @@ -4,7 +4,7 @@ MinLengthValidator as _MinLengthValidator, ) from django.utils.deconstruct import deconstructible -from django.utils.translation import ungettext_lazy +from django.utils.translation import ngettext_lazy @deconstructible @@ -14,7 +14,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", @@ -34,7 +34,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", From 190bafbd0e86c974852fb2143e0e1f11b31c68ec Mon Sep 17 00:00:00 2001 From: Bastien Vallet Date: Mon, 18 May 2020 11:55:28 +0200 Subject: [PATCH 5/8] Remove useless encoding declaration UTF-8 is default in Python3 --- .pre-commit-config.yaml | 1 - docs/conf.py | 1 - manage.py | 1 - setup.py | 1 - test_project/__init__.py | 1 - test_project/alchemy.py | 1 - test_project/generic/__init__.py | 1 - test_project/generic/api.py | 1 - test_project/generic/models.py | 1 - test_project/many_to_many/alchemy.py | 1 - test_project/many_to_many/api.py | 1 - test_project/many_to_many/models.py | 1 - test_project/many_to_one/alchemy.py | 1 - test_project/many_to_one/api.py | 1 - test_project/many_to_one/models.py | 1 - test_project/middleware.py | 1 - test_project/one_to_one/alchemy.py | 1 - test_project/one_to_one/api.py | 1 - test_project/one_to_one/models.py | 1 - test_project/settings.py | 1 - test_project/urls.py | 1 - tests/__init__.py | 1 - tests/backends/__init__.py | 1 - tests/backends/test_django.py | 1 - tests/backends/test_plain.py | 1 - tests/backends/test_sqlalchemy.py | 1 - tests/conftest.py | 1 - tests/filtersets/__init__.py | 1 - tests/filtersets/test_base.py | 1 - tests/filtersets/test_django.py | 1 - tests/filtersets/test_plain.py | 1 - tests/filtersets/test_sqlalchemy.py | 1 - tests/integrations/__init__.py | 1 - tests/integrations/test_drf.py | 1 - tests/integrations/test_drf_coreapi.py | 1 - tests/test_fields.py | 1 - tests/test_filters.py | 1 - tests/test_utils.py | 1 - url_filter/__init__.py | 1 - url_filter/backends/__init__.py | 1 - url_filter/backends/base.py | 1 - url_filter/backends/django.py | 1 - url_filter/backends/plain.py | 1 - url_filter/backends/sqlalchemy.py | 1 - url_filter/constants.py | 1 - url_filter/exceptions.py | 1 - url_filter/fields.py | 1 - url_filter/filters.py | 1 - url_filter/filtersets/__init__.py | 1 - url_filter/filtersets/base.py | 1 - url_filter/filtersets/django.py | 1 - url_filter/filtersets/plain.py | 1 - url_filter/filtersets/sqlalchemy.py | 1 - url_filter/integrations/drf.py | 1 - url_filter/integrations/drf_coreapi.py | 1 - url_filter/utils.py | 1 - url_filter/validators.py | 1 - 57 files changed, 57 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f6cbf7b..ab38b36 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,6 @@ 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 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/setup.py b/setup.py index 9d83d38..32e4cac 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- import os from setuptools import find_packages, setup diff --git a/test_project/__init__.py b/test_project/__init__.py index 40a96af..e69de29 100644 --- a/test_project/__init__.py +++ b/test_project/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/test_project/alchemy.py b/test_project/alchemy.py index 90a43ab..00ea8e1 100644 --- a/test_project/alchemy.py +++ b/test_project/alchemy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from sqlalchemy.ext.declarative import declarative_base diff --git a/test_project/generic/__init__.py b/test_project/generic/__init__.py index 40a96af..e69de29 100644 --- a/test_project/generic/__init__.py +++ b/test_project/generic/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/test_project/generic/api.py b/test_project/generic/api.py index 6c37852..700a57e 100644 --- a/test_project/generic/api.py +++ b/test_project/generic/api.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 2d33357..8a40c21 100644 --- a/test_project/generic/models.py +++ b/test_project/generic/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import six from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType diff --git a/test_project/many_to_many/alchemy.py b/test_project/many_to_many/alchemy.py index 88a57d8..3b6c6e9 100644 --- a/test_project/many_to_many/alchemy.py +++ b/test_project/many_to_many/alchemy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 b4dc3c5..35c7679 100644 --- a/test_project/many_to_many/api.py +++ b/test_project/many_to_many/api.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 f536e99..3ea03c8 100644 --- a/test_project/many_to_many/models.py +++ b/test_project/many_to_many/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import six from django.db import models diff --git a/test_project/many_to_one/alchemy.py b/test_project/many_to_one/alchemy.py index 2f9d9ab..563f202 100644 --- a/test_project/many_to_one/alchemy.py +++ b/test_project/many_to_one/alchemy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 f706e05..96c4b19 100644 --- a/test_project/many_to_one/api.py +++ b/test_project/many_to_one/api.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 b7b500a..36c4ff7 100644 --- a/test_project/many_to_one/models.py +++ b/test_project/many_to_one/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import six from django.db import models diff --git a/test_project/middleware.py b/test_project/middleware.py index d67e29a..6a57ec2 100644 --- a/test_project/middleware.py +++ b/test_project/middleware.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 f087d69..693049b 100644 --- a/test_project/one_to_one/alchemy.py +++ b/test_project/one_to_one/alchemy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 89a8093..26a271d 100644 --- a/test_project/one_to_one/api.py +++ b/test_project/one_to_one/api.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 8a46846..3bf5e0a 100644 --- a/test_project/one_to_one/models.py +++ b/test_project/one_to_one/models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import six from django.db import models 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 acce3bc..9853eac 100644 --- a/test_project/urls.py +++ b/test_project/urls.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 40a96af..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/tests/backends/__init__.py b/tests/backends/__init__.py index 40a96af..e69de29 100644 --- a/tests/backends/__init__.py +++ b/tests/backends/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/tests/backends/test_django.py b/tests/backends/test_django.py index ffb1004..a3397ce 100644 --- a/tests/backends/test_django.py +++ b/tests/backends/test_django.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 e8aec32..f06fd9d 100644 --- a/tests/backends/test_plain.py +++ b/tests/backends/test_plain.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 72b093f..84b52a3 100644 --- a/tests/backends/test_sqlalchemy.py +++ b/tests/backends/test_sqlalchemy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import pytest import six from alchemy_mock.comparison import ExpressionMatcher diff --git a/tests/conftest.py b/tests/conftest.py index 1c0f080..f8146d9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 40a96af..e69de29 100644 --- a/tests/filtersets/__init__.py +++ b/tests/filtersets/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/tests/filtersets/test_base.py b/tests/filtersets/test_base.py index 0015cc6..f4d7e04 100644 --- a/tests/filtersets/test_base.py +++ b/tests/filtersets/test_base.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 b60d8cb..2a158fd 100644 --- a/tests/filtersets/test_django.py +++ b/tests/filtersets/test_django.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 8ae9a40..0c296d8 100644 --- a/tests/filtersets/test_plain.py +++ b/tests/filtersets/test_plain.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 a63f0bc..d505310 100644 --- a/tests/filtersets/test_sqlalchemy.py +++ b/tests/filtersets/test_sqlalchemy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 40a96af..e69de29 100644 --- a/tests/integrations/__init__.py +++ b/tests/integrations/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/tests/integrations/test_drf.py b/tests/integrations/test_drf.py index b8f4e79..b8872ee 100644 --- a/tests/integrations/test_drf.py +++ b/tests/integrations/test_drf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 b071d8e..93dcc1b 100644 --- a/tests/integrations/test_drf_coreapi.py +++ b/tests/integrations/test_drf_coreapi.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 5d8891b..d0a03ab 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import pytest from django import forms diff --git a/tests/test_filters.py b/tests/test_filters.py index 9a30284..5457d66 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from functools import partial import mock diff --git a/tests/test_utils.py b/tests/test_utils.py index d2578dd..d910434 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from url_filter.utils import FilterSpec, LookupConfig, SubClassDict, dictify diff --git a/url_filter/__init__.py b/url_filter/__init__.py index eb1a0f7..783a9ba 100644 --- a/url_filter/__init__.py +++ b/url_filter/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- __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 40a96af..e69de29 100644 --- a/url_filter/backends/__init__.py +++ b/url_filter/backends/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/url_filter/backends/base.py b/url_filter/backends/base.py index 735e8cd..9fe53d0 100644 --- a/url_filter/backends/base.py +++ b/url_filter/backends/base.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import abc import six diff --git a/url_filter/backends/django.py b/url_filter/backends/django.py index ca5a13c..a559ff8 100644 --- a/url_filter/backends/django.py +++ b/url_filter/backends/django.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 8ef979a..31e7dcc 100644 --- a/url_filter/backends/plain.py +++ b/url_filter/backends/plain.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import re from ..utils import dictify diff --git a/url_filter/backends/sqlalchemy.py b/url_filter/backends/sqlalchemy.py index 8feca36..28d7015 100644 --- a/url_filter/backends/sqlalchemy.py +++ b/url_filter/backends/sqlalchemy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import itertools from sqlalchemy import false, func diff --git a/url_filter/constants.py b/url_filter/constants.py index 0a8c71a..b4c651b 100644 --- a/url_filter/constants.py +++ b/url_filter/constants.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import enum diff --git a/url_filter/exceptions.py b/url_filter/exceptions.py index b1a621c..cb07850 100644 --- a/url_filter/exceptions.py +++ b/url_filter/exceptions.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- class SkipFilter(Exception): """ Exception to be used when any particular filter diff --git a/url_filter/fields.py b/url_filter/fields.py index f448688..36d52a6 100644 --- a/url_filter/fields.py +++ b/url_filter/fields.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django import forms from .validators import MaxLengthValidator, MinLengthValidator diff --git a/url_filter/filters.py b/url_filter/filters.py index cc66297..7542042 100644 --- a/url_filter/filters.py +++ b/url_filter/filters.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import abc import re from functools import wraps diff --git a/url_filter/filtersets/__init__.py b/url_filter/filtersets/__init__.py index 5a7bae4..9b8851e 100644 --- a/url_filter/filtersets/__init__.py +++ b/url_filter/filtersets/__init__.py @@ -1,3 +1,2 @@ -# -*- coding: utf-8 -*- from .base import * # noqa from .django import * # noqa diff --git a/url_filter/filtersets/base.py b/url_filter/filtersets/base.py index 6bc9af1..f12f127 100644 --- a/url_filter/filtersets/base.py +++ b/url_filter/filtersets/base.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import abc import re from collections import defaultdict diff --git a/url_filter/filtersets/django.py b/url_filter/filtersets/django.py index 3158ed8..776f06b 100644 --- a/url_filter/filtersets/django.py +++ b/url_filter/filtersets/django.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import operator from django import forms diff --git a/url_filter/filtersets/plain.py b/url_filter/filtersets/plain.py index c221b99..8fd5223 100644 --- a/url_filter/filtersets/plain.py +++ b/url_filter/filtersets/plain.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from datetime import date, datetime, time from decimal import Decimal diff --git a/url_filter/filtersets/sqlalchemy.py b/url_filter/filtersets/sqlalchemy.py index b18668f..bfefcfe 100644 --- a/url_filter/filtersets/sqlalchemy.py +++ b/url_filter/filtersets/sqlalchemy.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import inspect from functools import partial diff --git a/url_filter/integrations/drf.py b/url_filter/integrations/drf.py index d6911f0..7d578c1 100644 --- a/url_filter/integrations/drf.py +++ b/url_filter/integrations/drf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- 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 8c06a18..3881f60 100644 --- a/url_filter/integrations/drf_coreapi.py +++ b/url_filter/integrations/drf_coreapi.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import coreapi import coreschema from django import forms diff --git a/url_filter/utils.py b/url_filter/utils.py index 1bc8aa2..914864d 100644 --- a/url_filter/utils.py +++ b/url_filter/utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import inspect from contextlib import contextmanager diff --git a/url_filter/validators.py b/url_filter/validators.py index 70c746c..0c6536f 100644 --- a/url_filter/validators.py +++ b/url_filter/validators.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.core.validators import ( MaxLengthValidator as _MaxLengthValidator, MinLengthValidator as _MinLengthValidator, From a7ef3a760365f42dc55e7d160921e1fac45066e3 Mon Sep 17 00:00:00 2001 From: Bastien Vallet Date: Mon, 18 May 2020 12:18:49 +0200 Subject: [PATCH 6/8] Fix .pre-commit-hooks - Use pycqa flake8 version - Remove default --safe black option --- .pre-commit-config.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ab38b36..35fb72e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,10 +19,14 @@ repos: args: [--allow-multiple-documents] - id: debug-statements - id: end-of-file-fixer - - 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: @@ -30,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/.*$ From 90fff869e50ce9ca3b4be9a75dfa522438bbb054 Mon Sep 17 00:00:00 2001 From: Bastien Vallet Date: Mon, 18 May 2020 14:04:53 +0200 Subject: [PATCH 7/8] Fix coverage in drone --- .drone.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.drone.yml b/.drone.yml index d55a4b3..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: @@ -45,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: From 5b93fe410e65c42755b36704dde2485f169ae477 Mon Sep 17 00:00:00 2001 From: Bastien Vallet Date: Mon, 18 May 2020 14:15:49 +0200 Subject: [PATCH 8/8] Remove dependency to six module --- requirements.txt | 3 +-- test_project/generic/models.py | 3 --- test_project/many_to_many/models.py | 3 --- test_project/many_to_one/models.py | 3 --- test_project/one_to_one/models.py | 4 ---- tests/backends/test_sqlalchemy.py | 9 ++++----- url_filter/backends/base.py | 3 +-- url_filter/filters.py | 7 ++----- url_filter/filtersets/base.py | 6 +++--- url_filter/filtersets/plain.py | 5 ++--- 10 files changed, 13 insertions(+), 33 deletions(-) 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/test_project/generic/models.py b/test_project/generic/models.py index 8a40c21..6d0bcba 100644 --- a/test_project/generic/models.py +++ b/test_project/generic/models.py @@ -1,10 +1,8 @@ -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) @@ -12,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/models.py b/test_project/many_to_many/models.py index 3ea03c8..fcaf53f 100644 --- a/test_project/many_to_many/models.py +++ b/test_project/many_to_many/models.py @@ -1,8 +1,6 @@ -import six from django.db import models -@six.python_2_unicode_compatible class Publication(models.Model): title = models.CharField(max_length=30) @@ -13,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/models.py b/test_project/many_to_one/models.py index 36c4ff7..65fb93c 100644 --- a/test_project/many_to_one/models.py +++ b/test_project/many_to_one/models.py @@ -1,8 +1,6 @@ -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) @@ -12,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/one_to_one/models.py b/test_project/one_to_one/models.py index 3bf5e0a..c51ddf8 100644 --- a/test_project/one_to_one/models.py +++ b/test_project/one_to_one/models.py @@ -1,8 +1,6 @@ -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) @@ -11,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) @@ -21,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/tests/backends/test_sqlalchemy.py b/tests/backends/test_sqlalchemy.py index 84b52a3..4c64a84 100644 --- a/tests/backends/test_sqlalchemy.py +++ b/tests/backends/test_sqlalchemy.py @@ -1,5 +1,4 @@ import pytest -import six from alchemy_mock.comparison import ExpressionMatcher from sqlalchemy import func from sqlalchemy.orm import joinedload @@ -31,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)) @@ -54,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 @@ -74,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 @@ -94,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/url_filter/backends/base.py b/url_filter/backends/base.py index 9fe53d0..5499f8c 100644 --- a/url_filter/backends/base.py +++ b/url_filter/backends/base.py @@ -1,10 +1,9 @@ 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/filters.py b/url_filter/filters.py index 7542042..a44dd57 100644 --- a/url_filter/filters.py +++ b/url_filter/filters.py @@ -2,7 +2,6 @@ import re from functools import wraps -import six from cached_property import cached_property from django import forms from django.core.exceptions import ValidationError @@ -38,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. @@ -73,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/base.py b/url_filter/filtersets/base.py index f12f127..7ed5579 100644 --- a/url_filter/filtersets/base.py +++ b/url_filter/filtersets/base.py @@ -1,9 +1,9 @@ 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 @@ -88,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. @@ -395,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/plain.py b/url_filter/filtersets/plain.py index 8fd5223..c2ce2de 100644 --- a/url_filter/filtersets/plain.py +++ b/url_filter/filtersets/plain.py @@ -1,7 +1,6 @@ from datetime import date, datetime, time from decimal import Decimal -import six from django import forms from ..backends.plain import PlainFilterBackend @@ -13,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(),