pending deprecations -> deprecated

This commit is contained in:
Tom Christie 2013-06-27 20:36:14 +01:00
parent 3fcc01273c
commit 379ad8a824
4 changed files with 42 additions and 42 deletions

View File

@ -108,11 +108,11 @@ class GenericAPIView(views.APIView):
deprecated_style = False deprecated_style = False
if page_size is not None: if page_size is not None:
warnings.warn('The `page_size` parameter to `paginate_queryset()` ' 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 ' 'Note that the return style of this method is also '
'changed, and will simply return a page object ' 'changed, and will simply return a page object '
'when called without a `page_size` argument.', 'when called without a `page_size` argument.',
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
deprecated_style = True deprecated_style = True
else: else:
# Determine the required page size. # Determine the required page size.
@ -123,10 +123,10 @@ class GenericAPIView(views.APIView):
if not self.allow_empty: if not self.allow_empty:
warnings.warn( 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 ' 'To use `allow_empty=False` style behavior, You should override '
'`get_queryset()` and explicitly raise a 404 on empty querysets.', '`get_queryset()` and explicitly raise a 404 on empty querysets.',
PendingDeprecationWarning, stacklevel=2 DeprecationWarning, stacklevel=2
) )
paginator = self.paginator_class(queryset, page_size, paginator = self.paginator_class(queryset, page_size,
@ -166,10 +166,10 @@ class GenericAPIView(views.APIView):
if not filter_backends and self.filter_backend: if not filter_backends and self.filter_backend:
warnings.warn( warnings.warn(
'The `filter_backend` attribute and `FILTER_BACKEND` setting ' '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 ' 'attribute and `DEFAULT_FILTER_BACKENDS` setting, that take '
'a *list* of filter backend classes.', 'a *list* of filter backend classes.',
PendingDeprecationWarning, stacklevel=2 DeprecationWarning, stacklevel=2
) )
filter_backends = [self.filter_backend] filter_backends = [self.filter_backend]
@ -192,8 +192,8 @@ class GenericAPIView(views.APIView):
""" """
if queryset is not None: if queryset is not None:
warnings.warn('The `queryset` parameter to `get_paginate_by()` ' warnings.warn('The `queryset` parameter to `get_paginate_by()` '
'is due to be deprecated.', 'is deprecated.',
PendingDeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
if self.paginate_by_param: if self.paginate_by_param:
query_params = self.request.QUERY_PARAMS query_params = self.request.QUERY_PARAMS
@ -272,16 +272,16 @@ class GenericAPIView(views.APIView):
filter_kwargs = {self.lookup_field: lookup} filter_kwargs = {self.lookup_field: lookup}
elif pk is not None and self.lookup_field == 'pk': elif pk is not None and self.lookup_field == 'pk':
warnings.warn( 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', 'Use the `lookup_field` attribute instead',
PendingDeprecationWarning DeprecationWarning
) )
filter_kwargs = {'pk': pk} filter_kwargs = {'pk': pk}
elif slug is not None and self.lookup_field == 'pk': elif slug is not None and self.lookup_field == 'pk':
warnings.warn( 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', 'Use the `lookup_field` attribute instead',
PendingDeprecationWarning DeprecationWarning
) )
filter_kwargs = {self.slug_field: slug} filter_kwargs = {self.slug_field: slug}
else: else:
@ -482,9 +482,9 @@ class RetrieveUpdateDestroyAPIView(mixins.RetrieveModelMixin,
class MultipleObjectAPIView(GenericAPIView): class MultipleObjectAPIView(GenericAPIView):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
warnings.warn( warnings.warn(
'Subclassing `MultipleObjectAPIView` is due to be deprecated. ' 'Subclassing `MultipleObjectAPIView` is deprecated. '
'You should simply subclass `GenericAPIView` instead.', 'You should simply subclass `GenericAPIView` instead.',
PendingDeprecationWarning, stacklevel=2 DeprecationWarning, stacklevel=2
) )
super(MultipleObjectAPIView, self).__init__(*args, **kwargs) super(MultipleObjectAPIView, self).__init__(*args, **kwargs)
@ -492,8 +492,8 @@ class MultipleObjectAPIView(GenericAPIView):
class SingleObjectAPIView(GenericAPIView): class SingleObjectAPIView(GenericAPIView):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
warnings.warn( warnings.warn(
'Subclassing `SingleObjectAPIView` is due to be deprecated. ' 'Subclassing `SingleObjectAPIView` is deprecated. '
'You should simply subclass `GenericAPIView` instead.', 'You should simply subclass `GenericAPIView` instead.',
PendingDeprecationWarning, stacklevel=2 DeprecationWarning, stacklevel=2
) )
super(SingleObjectAPIView, self).__init__(*args, **kwargs) super(SingleObjectAPIView, self).__init__(*args, **kwargs)

View File

@ -24,14 +24,14 @@ def _get_validation_exclusions(obj, pk=None, slug_field=None, lookup_field=None)
include = [] include = []
if pk: if pk:
# Pending deprecation # Deprecated
pk_field = obj._meta.pk pk_field = obj._meta.pk
while pk_field.rel: while pk_field.rel:
pk_field = pk_field.rel.to._meta.pk pk_field = pk_field.rel.to._meta.pk
include.append(pk_field.name) include.append(pk_field.name)
if slug_field: if slug_field:
# Pending deprecation # Deprecated
include.append(slug_field) include.append(slug_field)
if lookup_field and lookup_field != 'pk': if lookup_field and lookup_field != 'pk':
@ -77,10 +77,10 @@ class ListModelMixin(object):
# `.allow_empty = False`, to raise 404 errors on empty querysets. # `.allow_empty = False`, to raise 404 errors on empty querysets.
if not self.allow_empty and not self.object_list: if not self.allow_empty and not self.object_list:
warnings.warn( 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 ' 'To use `allow_empty=False` style behavior, You should override '
'`get_queryset()` and explicitly raise a 404 on empty querysets.', '`get_queryset()` and explicitly raise a 404 on empty querysets.',
PendingDeprecationWarning DeprecationWarning
) )
class_name = self.__class__.__name__ class_name = self.__class__.__name__
error_msg = self.empty_error % {'class_name': class_name} error_msg = self.empty_error % {'class_name': class_name}

View File

@ -314,7 +314,7 @@ class HyperlinkedRelatedField(RelatedField):
'incorrect_type': _('Incorrect type. Expected url string, received %s.'), 'incorrect_type': _('Incorrect type. Expected url string, received %s.'),
} }
# These are all pending deprecation # These are all deprecated
pk_url_kwarg = 'pk' pk_url_kwarg = 'pk'
slug_field = 'slug' slug_field = 'slug'
slug_url_kwarg = None # Defaults to same as `slug_field` unless overridden 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.lookup_field = kwargs.pop('lookup_field', self.lookup_field)
self.format = kwargs.pop('format', None) self.format = kwargs.pop('format', None)
# These are pending deprecation # These are deprecated
if 'pk_url_kwarg' in kwargs: if 'pk_url_kwarg' in kwargs:
msg = 'pk_url_kwarg is pending deprecation. Use lookup_field instead.' msg = 'pk_url_kwarg is deprecated. Use lookup_field instead.'
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) warnings.warn(msg, DeprecationWarning, stacklevel=2)
if 'slug_url_kwarg' in kwargs: if 'slug_url_kwarg' in kwargs:
msg = 'slug_url_kwarg is pending deprecation. Use lookup_field instead.' msg = 'slug_url_kwarg is deprecated. Use lookup_field instead.'
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) warnings.warn(msg, DeprecationWarning, stacklevel=2)
if 'slug_field' in kwargs: if 'slug_field' in kwargs:
msg = 'slug_field is pending deprecation. Use lookup_field instead.' msg = 'slug_field is deprecated. Use lookup_field instead.'
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) warnings.warn(msg, DeprecationWarning, stacklevel=2)
self.pk_url_kwarg = kwargs.pop('pk_url_kwarg', self.pk_url_kwarg) self.pk_url_kwarg = kwargs.pop('pk_url_kwarg', self.pk_url_kwarg)
self.slug_field = kwargs.pop('slug_field', self.slug_field) 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, # If the lookup succeeds using the default slug params,
# then `slug_field` is being used implicitly, and we # then `slug_field` is being used implicitly, and we
# we need to warn about the pending deprecation. # 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.' 'You should set `lookup_field=slug` on the HyperlinkedRelatedField.'
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) warnings.warn(msg, DeprecationWarning, stacklevel=2)
return ret return ret
except NoReverseMatch: except NoReverseMatch:
pass pass
@ -480,7 +480,7 @@ class HyperlinkedIdentityField(Field):
lookup_field = 'pk' lookup_field = 'pk'
read_only = True read_only = True
# These are all pending deprecation # These are all deprecated
pk_url_kwarg = 'pk' pk_url_kwarg = 'pk'
slug_field = 'slug' slug_field = 'slug'
slug_url_kwarg = None # Defaults to same as `slug_field` unless overridden 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) lookup_field = kwargs.pop('lookup_field', None)
self.lookup_field = lookup_field or self.lookup_field self.lookup_field = lookup_field or self.lookup_field
# These are pending deprecation # These are deprecated
if 'pk_url_kwarg' in kwargs: if 'pk_url_kwarg' in kwargs:
msg = 'pk_url_kwarg is pending deprecation. Use lookup_field instead.' msg = 'pk_url_kwarg is deprecated. Use lookup_field instead.'
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) warnings.warn(msg, DeprecationWarning, stacklevel=2)
if 'slug_url_kwarg' in kwargs: if 'slug_url_kwarg' in kwargs:
msg = 'slug_url_kwarg is pending deprecation. Use lookup_field instead.' msg = 'slug_url_kwarg is deprecated. Use lookup_field instead.'
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) warnings.warn(msg, DeprecationWarning, stacklevel=2)
if 'slug_field' in kwargs: if 'slug_field' in kwargs:
msg = 'slug_field is pending deprecation. Use lookup_field instead.' msg = 'slug_field is deprecated. Use lookup_field instead.'
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2) warnings.warn(msg, DeprecationWarning, stacklevel=2)
self.slug_field = kwargs.pop('slug_field', self.slug_field) self.slug_field = kwargs.pop('slug_field', self.slug_field)
default_slug_kwarg = self.slug_url_kwarg or self.slug_field default_slug_kwarg = self.slug_url_kwarg or self.slug_field

View File

@ -593,10 +593,10 @@ class ModelSerializer(Serializer):
if len(inspect.getargspec(self.get_nested_field).args) == 2: if len(inspect.getargspec(self.get_nested_field).args) == 2:
warnings.warn( warnings.warn(
'The `get_nested_field(model_field)` call signature ' 'The `get_nested_field(model_field)` call signature '
'is due to be deprecated. ' 'is deprecated. '
'Use `get_nested_field(model_field, related_model, ' 'Use `get_nested_field(model_field, related_model, '
'to_many) instead', 'to_many) instead',
PendingDeprecationWarning DeprecationWarning
) )
field = self.get_nested_field(model_field) field = self.get_nested_field(model_field)
else: else:
@ -605,10 +605,10 @@ class ModelSerializer(Serializer):
if len(inspect.getargspec(self.get_nested_field).args) == 3: if len(inspect.getargspec(self.get_nested_field).args) == 3:
warnings.warn( warnings.warn(
'The `get_related_field(model_field, to_many)` call ' '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, ' 'Use `get_related_field(model_field, related_model, '
'to_many) instead', 'to_many) instead',
PendingDeprecationWarning DeprecationWarning
) )
field = self.get_related_field(model_field, to_many=to_many) field = self.get_related_field(model_field, to_many=to_many)
else: else: