Drop Python2.7 support.

This commit is contained in:
Hasan Ramezani 2020-11-22 23:07:36 +01:00
parent cbe59ddb7b
commit 4b2c6f8e02
No known key found for this signature in database
GPG key ID: 36462AEA74DF3539
13 changed files with 15 additions and 38 deletions

View file

@ -2,7 +2,6 @@ language: python
dist: xenial
cache: pip
python:
- '2.7'
- '3.5'
- '3.6'
- '3.7'

View file

@ -6,6 +6,10 @@ django-defender
:target: https://jazzband.co/
:alt: Jazzband
.. image:: https://img.shields.io/pypi/pyversions/django-defender.svg
:alt: Supported Python versions
:target: https://pypi.org/project/django-defender/
.. image:: https://travis-ci.org/jazzband/django-defender.svg
:target: https://travis-ci.org/jazzband/django-defender
:alt: Build Status
@ -100,7 +104,7 @@ Admin pages
Requirements
------------
* Python: 2.7, 3.5, 3.6, 3.7, 3.8, PyPy
* Python: 3.5, 3.6, 3.7, 3.8, PyPy
* Django: 1.11, 2.1, 2.2, 3.x
* Redis

View file

@ -1,12 +1,9 @@
from django.core.cache import caches
from django.core.cache.backends.base import InvalidCacheBackendError
import urllib.parse as urlparse
import redis
try:
import urlparse
except ImportError: # pragma: no cover
import urllib.parse as urlparse # pragma: no cover # Python3 # pylint: disable=import-error,no-name-in-module,line-too-long
from django.core.cache import caches
from django.core.cache.backends.base import InvalidCacheBackendError
from . import config

View file

@ -1,4 +1,3 @@
from __future__ import print_function
from datetime import timedelta
from django.core.management.base import BaseCommand

View file

@ -14,7 +14,7 @@ class FailedLoginMiddleware(MIDDLEWARE_BASE_CLASS):
patched = False
def __init__(self, *args, **kwargs):
super(FailedLoginMiddleware, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
# Watch the auth login.
# Monkey-patch only once - otherwise we would be recording
# failed attempts multiple times!

View file

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations

View file

@ -1,16 +1,6 @@
from __future__ import unicode_literals
import django
from django.db import models
if django.VERSION[0] < 3:
from django.utils.encoding import python_2_unicode_compatible
else:
# noop stub
def python_2_unicode_compatible(cls):
return cls
@python_2_unicode_compatible
class AccessAttempt(models.Model):
""" Access Attempt log """

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration

View file

@ -8,7 +8,7 @@ class DefenderTestCaseMixin(object):
def tearDown(self):
"""cleanup django-defender cache after each test"""
super(DefenderTestCaseMixin, self).tearDown()
super().tearDown()
get_redis_connection().flushdb()

View file

@ -2,12 +2,7 @@ import random
import string
import time
from distutils.version import StrictVersion
# Python 3 has mock in the stdlib
try:
from mock import patch
except ImportError:
from unittest.mock import patch
from unittest.mock import patch
from django import get_version
from django.contrib.auth.models import User

View file

@ -3,4 +3,3 @@ coverage
mockredispy
django-redis-cache==2.1.1
celery<5
mock; python_version < '3.0'

View file

@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from setuptools import setup, find_packages
@ -36,7 +35,8 @@ setup(
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
@ -56,9 +56,9 @@ setup(
include_package_data=True,
packages=find_packages(),
package_data=get_package_data("defender"),
python_requires='~=3.5',
install_requires=["Django>=1.8,<3.2", "redis<3.6"],
tests_require=[
"mock",
"mockredispy>=2.9.0.11,<3.0",
"coverage",
"celery",

View file

@ -2,7 +2,7 @@
envlist =
# list of supported Django/Python versioons:
# https://docs.djangoproject.com/en/2.2/faq/install/#what-python-version-can-i-use-with-django
py{27,35,36,37,py3}-django111
py{35,36,37,py3}-django111
py35-django(21,22)
py{36,37,py3}-django{21,22,master}
py38-django22
@ -10,7 +10,6 @@ envlist =
[travis]
python =
2.7: py27
3.5: py35
3.6: py36
3.7: py37
@ -20,7 +19,6 @@ python =
[testenv]
deps =
-rrequirements.txt
py27: mock
django111: django>=1.11,<2.0
django21: django>=2.1,<2.2
django22: django>=2.2,<2.3