From cfd73825a8eaf32f4de9a73d059db25b2d670e0f Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Tue, 2 Oct 2018 11:59:10 +0200 Subject: [PATCH] Updated list_route() and detail_route() deprecations. --- rest_framework/decorators.py | 8 ++++---- rest_framework/routers.py | 8 ++++---- rest_framework/schemas/generators.py | 1 - tests/test_decorators.py | 10 +++++----- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index 6dd769d4c..f6d557d11 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -223,9 +223,9 @@ def detail_route(methods=None, **kwargs): Used to mark a method on a ViewSet that should be routed for detail requests. """ warnings.warn( - "`detail_route` is pending deprecation and will be removed in 3.10 in favor of " + "`detail_route` is deprecated and will be removed in 3.10 in favor of " "`action`, which accepts a `detail` bool. Use `@action(detail=True)` instead.", - PendingDeprecationWarning, stacklevel=2 + DeprecationWarning, stacklevel=2 ) def decorator(func): @@ -241,9 +241,9 @@ def list_route(methods=None, **kwargs): Used to mark a method on a ViewSet that should be routed for list requests. """ warnings.warn( - "`list_route` is pending deprecation and will be removed in 3.10 in favor of " + "`list_route` is deprecated and will be removed in 3.10 in favor of " "`action`, which accepts a `detail` bool. Use `@action(detail=False)` instead.", - PendingDeprecationWarning, stacklevel=2 + DeprecationWarning, stacklevel=2 ) def decorator(func): diff --git a/rest_framework/routers.py b/rest_framework/routers.py index 392d43f79..db1492c45 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -40,10 +40,10 @@ DynamicRoute = namedtuple('DynamicRoute', ['url', 'name', 'detail', 'initkwargs' class DynamicDetailRoute(object): def __new__(cls, url, name, initkwargs): warnings.warn( - "`DynamicDetailRoute` is pending deprecation and will be removed in 3.10 " + "`DynamicDetailRoute` is deprecated and will be removed in 3.10 " "in favor of `DynamicRoute`, which accepts a `detail` boolean. Use " "`DynamicRoute(url, name, True, initkwargs)` instead.", - PendingDeprecationWarning, stacklevel=2 + DeprecationWarning, stacklevel=2 ) return DynamicRoute(url, name, True, initkwargs) @@ -51,10 +51,10 @@ class DynamicDetailRoute(object): class DynamicListRoute(object): def __new__(cls, url, name, initkwargs): warnings.warn( - "`DynamicListRoute` is pending deprecation and will be removed in 3.10 in " + "`DynamicListRoute` is deprecated and will be removed in 3.10 in " "favor of `DynamicRoute`, which accepts a `detail` boolean. Use " "`DynamicRoute(url, name, False, initkwargs)` instead.", - PendingDeprecationWarning, stacklevel=2 + DeprecationWarning, stacklevel=2 ) return DynamicRoute(url, name, False, initkwargs) diff --git a/rest_framework/schemas/generators.py b/rest_framework/schemas/generators.py index 116ca1819..c5bda1f1f 100644 --- a/rest_framework/schemas/generators.py +++ b/rest_framework/schemas/generators.py @@ -4,7 +4,6 @@ generators.py # Top-down schema generation See schemas.__init__.py for package overview. """ import re -import warnings from collections import Counter, OrderedDict from importlib import import_module diff --git a/tests/test_decorators.py b/tests/test_decorators.py index 77c488c34..9c6a899bf 100644 --- a/tests/test_decorators.py +++ b/tests/test_decorators.py @@ -290,34 +290,34 @@ class ActionDecoratorTestCase(TestCase): raise NotImplementedError def test_detail_route_deprecation(self): - with pytest.warns(PendingDeprecationWarning) as record: + with pytest.warns(DeprecationWarning) as record: @detail_route() def view(request): raise NotImplementedError assert len(record) == 1 assert str(record[0].message) == ( - "`detail_route` is pending deprecation and will be removed in " + "`detail_route` is deprecated and will be removed in " "3.10 in favor of `action`, which accepts a `detail` bool. Use " "`@action(detail=True)` instead." ) def test_list_route_deprecation(self): - with pytest.warns(PendingDeprecationWarning) as record: + with pytest.warns(DeprecationWarning) as record: @list_route() def view(request): raise NotImplementedError assert len(record) == 1 assert str(record[0].message) == ( - "`list_route` is pending deprecation and will be removed in " + "`list_route` is deprecated and will be removed in " "3.10 in favor of `action`, which accepts a `detail` bool. Use " "`@action(detail=False)` instead." ) def test_route_url_name_from_path(self): # pre-3.8 behavior was to base the `url_name` off of the `url_path` - with pytest.warns(PendingDeprecationWarning): + with pytest.warns(DeprecationWarning): @list_route(url_path='foo_bar') def view(request): raise NotImplementedError