mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Reenable flake8 on compat, cleanup style/imports
This commit is contained in:
parent
f8e8381c00
commit
5f8438697a
|
@ -3,7 +3,6 @@ The `compat` module provides support for backwards compatibility with older
|
|||
versions of Django/Python, and compatibility wrappers around optional packages.
|
||||
"""
|
||||
|
||||
# flake8: noqa
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import inspect
|
||||
|
@ -11,15 +10,9 @@ import inspect
|
|||
import django
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured, ValidationError
|
||||
from django.core.validators import \
|
||||
MaxLengthValidator as DjangoMaxLengthValidator
|
||||
from django.core.validators import MaxValueValidator as DjangoMaxValueValidator
|
||||
from django.core.validators import \
|
||||
MinLengthValidator as DjangoMinLengthValidator
|
||||
from django.core.validators import MinValueValidator as DjangoMinValueValidator
|
||||
from django.core import validators
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import connection, models, transaction
|
||||
from django.template import Context, RequestContext, Template
|
||||
from django.utils import six
|
||||
from django.views.generic import View
|
||||
|
||||
|
@ -152,7 +145,7 @@ except ImportError:
|
|||
guardian = None
|
||||
try:
|
||||
if 'guardian' in settings.INSTALLED_APPS:
|
||||
import guardian
|
||||
import guardian # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
@ -254,7 +247,7 @@ else:
|
|||
return False
|
||||
|
||||
try:
|
||||
import pytz
|
||||
import pytz # noqa
|
||||
from pytz.exceptions import InvalidTimeError
|
||||
except ImportError:
|
||||
InvalidTimeError = Exception
|
||||
|
@ -279,22 +272,28 @@ class CustomValidatorMessage(object):
|
|||
|
||||
Ref: https://github.com/encode/django-rest-framework/pull/5452
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.message = kwargs.pop('message', self.message)
|
||||
super(CustomValidatorMessage, self).__init__(*args, **kwargs)
|
||||
|
||||
class MinValueValidator(CustomValidatorMessage, DjangoMinValueValidator):
|
||||
|
||||
class MinValueValidator(CustomValidatorMessage, validators.MinValueValidator):
|
||||
pass
|
||||
|
||||
class MaxValueValidator(CustomValidatorMessage, DjangoMaxValueValidator):
|
||||
|
||||
class MaxValueValidator(CustomValidatorMessage, validators.MaxValueValidator):
|
||||
pass
|
||||
|
||||
class MinLengthValidator(CustomValidatorMessage, DjangoMinLengthValidator):
|
||||
|
||||
class MinLengthValidator(CustomValidatorMessage, validators.MinLengthValidator):
|
||||
pass
|
||||
|
||||
class MaxLengthValidator(CustomValidatorMessage, DjangoMaxLengthValidator):
|
||||
|
||||
class MaxLengthValidator(CustomValidatorMessage, validators.MaxLengthValidator):
|
||||
pass
|
||||
|
||||
|
||||
def set_rollback():
|
||||
if hasattr(transaction, 'set_rollback'):
|
||||
if connection.settings_dict.get('ATOMIC_REQUESTS', False):
|
||||
|
@ -318,4 +317,3 @@ def authenticate(request=None, **credentials):
|
|||
return authenticate(**credentials)
|
||||
else:
|
||||
return authenticate(request=request, **credentials)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user