mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
pending deprecations -> deprecated
This commit is contained in:
parent
3fcc01273c
commit
379ad8a824
|
@ -108,11 +108,11 @@ class GenericAPIView(views.APIView):
|
|||
deprecated_style = False
|
||||
if page_size is not None:
|
||||
warnings.warn('The `page_size` parameter to `paginate_queryset()` '
|
||||
'is due to be deprecated. '
|
||||
'is deprecated. '
|
||||
'Note that the return style of this method is also '
|
||||
'changed, and will simply return a page object '
|
||||
'when called without a `page_size` argument.',
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
DeprecationWarning, stacklevel=2)
|
||||
deprecated_style = True
|
||||
else:
|
||||
# Determine the required page size.
|
||||
|
@ -123,10 +123,10 @@ class GenericAPIView(views.APIView):
|
|||
|
||||
if not self.allow_empty:
|
||||
warnings.warn(
|
||||
'The `allow_empty` parameter is due to be deprecated. '
|
||||
'The `allow_empty` parameter is deprecated. '
|
||||
'To use `allow_empty=False` style behavior, You should override '
|
||||
'`get_queryset()` and explicitly raise a 404 on empty querysets.',
|
||||
PendingDeprecationWarning, stacklevel=2
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
|
||||
paginator = self.paginator_class(queryset, page_size,
|
||||
|
@ -166,10 +166,10 @@ class GenericAPIView(views.APIView):
|
|||
if not filter_backends and self.filter_backend:
|
||||
warnings.warn(
|
||||
'The `filter_backend` attribute and `FILTER_BACKEND` setting '
|
||||
'are due to be deprecated in favor of a `filter_backends` '
|
||||
'are deprecated in favor of a `filter_backends` '
|
||||
'attribute and `DEFAULT_FILTER_BACKENDS` setting, that take '
|
||||
'a *list* of filter backend classes.',
|
||||
PendingDeprecationWarning, stacklevel=2
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
filter_backends = [self.filter_backend]
|
||||
|
||||
|
@ -192,8 +192,8 @@ class GenericAPIView(views.APIView):
|
|||
"""
|
||||
if queryset is not None:
|
||||
warnings.warn('The `queryset` parameter to `get_paginate_by()` '
|
||||
'is due to be deprecated.',
|
||||
PendingDeprecationWarning, stacklevel=2)
|
||||
'is deprecated.',
|
||||
DeprecationWarning, stacklevel=2)
|
||||
|
||||
if self.paginate_by_param:
|
||||
query_params = self.request.QUERY_PARAMS
|
||||
|
@ -272,16 +272,16 @@ class GenericAPIView(views.APIView):
|
|||
filter_kwargs = {self.lookup_field: lookup}
|
||||
elif pk is not None and self.lookup_field == 'pk':
|
||||
warnings.warn(
|
||||
'The `pk_url_kwarg` attribute is due to be deprecated. '
|
||||
'The `pk_url_kwarg` attribute is deprecated. '
|
||||
'Use the `lookup_field` attribute instead',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
filter_kwargs = {'pk': pk}
|
||||
elif slug is not None and self.lookup_field == 'pk':
|
||||
warnings.warn(
|
||||
'The `slug_url_kwarg` attribute is due to be deprecated. '
|
||||
'The `slug_url_kwarg` attribute is deprecated. '
|
||||
'Use the `lookup_field` attribute instead',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
filter_kwargs = {self.slug_field: slug}
|
||||
else:
|
||||
|
@ -482,9 +482,9 @@ class RetrieveUpdateDestroyAPIView(mixins.RetrieveModelMixin,
|
|||
class MultipleObjectAPIView(GenericAPIView):
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn(
|
||||
'Subclassing `MultipleObjectAPIView` is due to be deprecated. '
|
||||
'Subclassing `MultipleObjectAPIView` is deprecated. '
|
||||
'You should simply subclass `GenericAPIView` instead.',
|
||||
PendingDeprecationWarning, stacklevel=2
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
super(MultipleObjectAPIView, self).__init__(*args, **kwargs)
|
||||
|
||||
|
@ -492,8 +492,8 @@ class MultipleObjectAPIView(GenericAPIView):
|
|||
class SingleObjectAPIView(GenericAPIView):
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn(
|
||||
'Subclassing `SingleObjectAPIView` is due to be deprecated. '
|
||||
'Subclassing `SingleObjectAPIView` is deprecated. '
|
||||
'You should simply subclass `GenericAPIView` instead.',
|
||||
PendingDeprecationWarning, stacklevel=2
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
super(SingleObjectAPIView, self).__init__(*args, **kwargs)
|
||||
|
|
|
@ -24,14 +24,14 @@ def _get_validation_exclusions(obj, pk=None, slug_field=None, lookup_field=None)
|
|||
include = []
|
||||
|
||||
if pk:
|
||||
# Pending deprecation
|
||||
# Deprecated
|
||||
pk_field = obj._meta.pk
|
||||
while pk_field.rel:
|
||||
pk_field = pk_field.rel.to._meta.pk
|
||||
include.append(pk_field.name)
|
||||
|
||||
if slug_field:
|
||||
# Pending deprecation
|
||||
# Deprecated
|
||||
include.append(slug_field)
|
||||
|
||||
if lookup_field and lookup_field != 'pk':
|
||||
|
@ -77,10 +77,10 @@ class ListModelMixin(object):
|
|||
# `.allow_empty = False`, to raise 404 errors on empty querysets.
|
||||
if not self.allow_empty and not self.object_list:
|
||||
warnings.warn(
|
||||
'The `allow_empty` parameter is due to be deprecated. '
|
||||
'The `allow_empty` parameter is deprecated. '
|
||||
'To use `allow_empty=False` style behavior, You should override '
|
||||
'`get_queryset()` and explicitly raise a 404 on empty querysets.',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
class_name = self.__class__.__name__
|
||||
error_msg = self.empty_error % {'class_name': class_name}
|
||||
|
|
|
@ -314,7 +314,7 @@ class HyperlinkedRelatedField(RelatedField):
|
|||
'incorrect_type': _('Incorrect type. Expected url string, received %s.'),
|
||||
}
|
||||
|
||||
# These are all pending deprecation
|
||||
# These are all deprecated
|
||||
pk_url_kwarg = 'pk'
|
||||
slug_field = 'slug'
|
||||
slug_url_kwarg = None # Defaults to same as `slug_field` unless overridden
|
||||
|
@ -328,16 +328,16 @@ class HyperlinkedRelatedField(RelatedField):
|
|||
self.lookup_field = kwargs.pop('lookup_field', self.lookup_field)
|
||||
self.format = kwargs.pop('format', None)
|
||||
|
||||
# These are pending deprecation
|
||||
# These are deprecated
|
||||
if 'pk_url_kwarg' in kwargs:
|
||||
msg = 'pk_url_kwarg is pending deprecation. Use lookup_field instead.'
|
||||
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
||||
msg = 'pk_url_kwarg is deprecated. Use lookup_field instead.'
|
||||
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
||||
if 'slug_url_kwarg' in kwargs:
|
||||
msg = 'slug_url_kwarg is pending deprecation. Use lookup_field instead.'
|
||||
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
||||
msg = 'slug_url_kwarg is deprecated. Use lookup_field instead.'
|
||||
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
||||
if 'slug_field' in kwargs:
|
||||
msg = 'slug_field is pending deprecation. Use lookup_field instead.'
|
||||
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
||||
msg = 'slug_field is deprecated. Use lookup_field instead.'
|
||||
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
||||
|
||||
self.pk_url_kwarg = kwargs.pop('pk_url_kwarg', self.pk_url_kwarg)
|
||||
self.slug_field = kwargs.pop('slug_field', self.slug_field)
|
||||
|
@ -380,9 +380,9 @@ class HyperlinkedRelatedField(RelatedField):
|
|||
# If the lookup succeeds using the default slug params,
|
||||
# then `slug_field` is being used implicitly, and we
|
||||
# we need to warn about the pending deprecation.
|
||||
msg = 'Implicit slug field hyperlinked fields are pending deprecation.' \
|
||||
msg = 'Implicit slug field hyperlinked fields are deprecated.' \
|
||||
'You should set `lookup_field=slug` on the HyperlinkedRelatedField.'
|
||||
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
||||
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
||||
return ret
|
||||
except NoReverseMatch:
|
||||
pass
|
||||
|
@ -480,7 +480,7 @@ class HyperlinkedIdentityField(Field):
|
|||
lookup_field = 'pk'
|
||||
read_only = True
|
||||
|
||||
# These are all pending deprecation
|
||||
# These are all deprecated
|
||||
pk_url_kwarg = 'pk'
|
||||
slug_field = 'slug'
|
||||
slug_url_kwarg = None # Defaults to same as `slug_field` unless overridden
|
||||
|
@ -496,16 +496,16 @@ class HyperlinkedIdentityField(Field):
|
|||
lookup_field = kwargs.pop('lookup_field', None)
|
||||
self.lookup_field = lookup_field or self.lookup_field
|
||||
|
||||
# These are pending deprecation
|
||||
# These are deprecated
|
||||
if 'pk_url_kwarg' in kwargs:
|
||||
msg = 'pk_url_kwarg is pending deprecation. Use lookup_field instead.'
|
||||
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
||||
msg = 'pk_url_kwarg is deprecated. Use lookup_field instead.'
|
||||
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
||||
if 'slug_url_kwarg' in kwargs:
|
||||
msg = 'slug_url_kwarg is pending deprecation. Use lookup_field instead.'
|
||||
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
||||
msg = 'slug_url_kwarg is deprecated. Use lookup_field instead.'
|
||||
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
||||
if 'slug_field' in kwargs:
|
||||
msg = 'slug_field is pending deprecation. Use lookup_field instead.'
|
||||
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
|
||||
msg = 'slug_field is deprecated. Use lookup_field instead.'
|
||||
warnings.warn(msg, DeprecationWarning, stacklevel=2)
|
||||
|
||||
self.slug_field = kwargs.pop('slug_field', self.slug_field)
|
||||
default_slug_kwarg = self.slug_url_kwarg or self.slug_field
|
||||
|
|
|
@ -593,10 +593,10 @@ class ModelSerializer(Serializer):
|
|||
if len(inspect.getargspec(self.get_nested_field).args) == 2:
|
||||
warnings.warn(
|
||||
'The `get_nested_field(model_field)` call signature '
|
||||
'is due to be deprecated. '
|
||||
'is deprecated. '
|
||||
'Use `get_nested_field(model_field, related_model, '
|
||||
'to_many) instead',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
field = self.get_nested_field(model_field)
|
||||
else:
|
||||
|
@ -605,10 +605,10 @@ class ModelSerializer(Serializer):
|
|||
if len(inspect.getargspec(self.get_nested_field).args) == 3:
|
||||
warnings.warn(
|
||||
'The `get_related_field(model_field, to_many)` call '
|
||||
'signature is due to be deprecated. '
|
||||
'signature is deprecated. '
|
||||
'Use `get_related_field(model_field, related_model, '
|
||||
'to_many) instead',
|
||||
PendingDeprecationWarning
|
||||
DeprecationWarning
|
||||
)
|
||||
field = self.get_related_field(model_field, to_many=to_many)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user