Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Python 2 support. #6277

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
26b6129
dropped python2.7 from tox and travis
auvipy Oct 24, 2018
cbafc5a
dropped python2.7 from readme
auvipy Oct 25, 2018
244d233
dropped python 2.7 compat code
auvipy Oct 25, 2018
0aa2958
Merge branch 'py2drop' of https://github.com/auvipy/django-rest-frame…
auvipy Oct 25, 2018
7e87449
dropped python 2.7 compat code from tests
auvipy Oct 25, 2018
5a6747d
dropped python 2.7 compat codes
auvipy Oct 25, 2018
d00211b
dropped python 2.7 compat codes from tests
auvipy Oct 25, 2018
87e603e
removed old style object inheritance and super() call from authtocken…
auvipy Oct 25, 2018
b1bbbc8
removed old style object inheritance, super() call and python2compat …
auvipy Oct 25, 2018
8e52e7f
fixed isort issue
auvipy Oct 25, 2018
47036c0
removed old style object inheritance and super() call
auvipy Oct 25, 2018
15a3952
kept a super() call explicit due to https://stackoverflow.com/questio…
auvipy Oct 25, 2018
a63a68c
kept a super() call explicit due to https://stackoverflow.com/questio…
auvipy Oct 25, 2018
7e0d416
fixed merge conflicts
auvipy Mar 4, 2019
b1b56ee
fixed isort failures
auvipy Mar 6, 2019
1b817d9
remove more python2 compat codes from tests
auvipy Mar 10, 2019
bcf64e5
remove more python2 compat codes
auvipy Mar 10, 2019
ebb1a23
Merge branch 'master' of https://github.com/encode/django-rest-framew…
auvipy Mar 20, 2019
30dc38b
Merge branch 'master' of https://github.com/encode/django-rest-framew…
auvipy Mar 31, 2019
f734344
isort fix
auvipy Mar 31, 2019
c2c11a5
remove six codes from compat
auvipy Mar 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dist: xenial
matrix:
fast_finish: true
include:
- { python: "2.7", env: DJANGO=1.11 }

- { python: "3.4", env: DJANGO=1.11 }
- { python: "3.4", env: DJANGO=2.0 }
Expand All @@ -25,9 +24,10 @@ matrix:
- { python: "3.7", env: DJANGO=2.2 }
- { python: "3.7", env: DJANGO=master }

- { python: "3.7", env: TOXENV=base }
- { python: "2.7", env: TOXENV=lint }
- { python: "2.7", env: TOXENV=docs }
- { python: "3.6", env: TOXENV=base }
- { python: "3.6", env: TOXENV=lint }
- { python: "3.6", env: TOXENV=docs }


- python: "3.7"
env: TOXENV=dist
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ There is a live example API for testing purposes, [available here][sandbox].

# Requirements

* Python (2.7, 3.4, 3.5, 3.6, 3.7)
* Python (3.4, 3.5, 3.6, 3.7)
* Django (1.11, 2.0, 2.1, 2.2)


We **highly recommend** and only officially support the latest patch release of
each Python and Django series.

Expand Down
3 changes: 1 addition & 2 deletions rest_framework/authentication.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Provides various authentication policies.
"""
from __future__ import unicode_literals

import base64
import binascii
Expand Down Expand Up @@ -33,7 +32,7 @@ def _reject(self, request, reason):
return reason


class BaseAuthentication(object):
class BaseAuthentication:
"""
All authentication classes should extend BaseAuthentication.
"""
Expand Down
3 changes: 0 additions & 3 deletions rest_framework/authtoken/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models

Expand Down
4 changes: 1 addition & 3 deletions rest_framework/authtoken/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@

from django.conf import settings
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _


@python_2_unicode_compatible
class Token(models.Model):
"""
The default authorization token model.
Expand All @@ -32,7 +30,7 @@ class Meta:
def save(self, *args, **kwargs):
if not self.key:
self.key = self.generate_key()
return super(Token, self).save(*args, **kwargs)
return super().save(*args, **kwargs)

def generate_key(self):
return binascii.hexlify(os.urandom(20)).decode()
Expand Down
2 changes: 0 additions & 2 deletions rest_framework/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
versions of Django/Python, and compatibility wrappers around optional packages.
"""

from __future__ import unicode_literals

import sys

from django.conf import settings
Expand Down
1 change: 0 additions & 1 deletion rest_framework/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
based views, as well as the `@detail_route` and `@list_route` decorators, which are
used to annotate methods on viewsets that should be included by routers.
"""
from __future__ import unicode_literals

import types
import warnings
Expand Down
11 changes: 5 additions & 6 deletions rest_framework/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
In addition Django's built in 403 and 404 exceptions are handled.
(`django.http.Http404` and `django.core.exceptions.PermissionDenied`)
"""
from __future__ import unicode_literals

import math

Expand Down Expand Up @@ -76,7 +75,7 @@ def __new__(cls, string, code=None):
return self

def __eq__(self, other):
r = super(ErrorDetail, self).__eq__(other)
r = super().__eq__(other)
try:
return r and self.code == other.code
except AttributeError:
Expand Down Expand Up @@ -196,7 +195,7 @@ class MethodNotAllowed(APIException):
def __init__(self, method, detail=None, code=None):
if detail is None:
detail = force_text(self.default_detail).format(method=method)
super(MethodNotAllowed, self).__init__(detail, code)
super().__init__(detail, code)


class NotAcceptable(APIException):
Expand All @@ -206,7 +205,7 @@ class NotAcceptable(APIException):

def __init__(self, detail=None, code=None, available_renderers=None):
self.available_renderers = available_renderers
super(NotAcceptable, self).__init__(detail, code)
super().__init__(detail, code)


class UnsupportedMediaType(APIException):
Expand All @@ -217,7 +216,7 @@ class UnsupportedMediaType(APIException):
def __init__(self, media_type, detail=None, code=None):
if detail is None:
detail = force_text(self.default_detail).format(media_type=media_type)
super(UnsupportedMediaType, self).__init__(detail, code)
super().__init__(detail, code)


class Throttled(APIException):
Expand All @@ -238,7 +237,7 @@ def __init__(self, wait=None, detail=None, code=None):
self.extra_detail_plural.format(wait=wait),
wait))))
self.wait = wait
super(Throttled, self).__init__(detail, code)
super().__init__(detail, code)


def server_error(request, *args, **kwargs):
Expand Down
Loading