From 7fb11bf2f50c1a85d551d56b9275295c62907d77 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Tue, 2 Oct 2018 11:42:32 +0200 Subject: [PATCH] Removed exclude_from_schema per deprecation policy. --- rest_framework/decorators.py | 11 ++-------- rest_framework/schemas/generators.py | 8 ------- tests/test_schemas.py | 32 ---------------------------- 3 files changed, 2 insertions(+), 49 deletions(-) diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index 2d3bbe46f..6dd769d4c 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -17,7 +17,7 @@ from django.utils import six from rest_framework.views import APIView -def api_view(http_method_names=None, exclude_from_schema=False): +def api_view(http_method_names=None): """ Decorator that converts a function-based view into an APIView subclass. Takes a list of allowed methods for the view as an argument. @@ -77,15 +77,8 @@ def api_view(http_method_names=None, exclude_from_schema=False): WrappedAPIView.schema = getattr(func, 'schema', APIView.schema) - if exclude_from_schema: - warnings.warn( - "The `exclude_from_schema` argument to `api_view` is deprecated. " - "Use the `schema` decorator instead, passing `None`.", - DeprecationWarning - ) - WrappedAPIView.exclude_from_schema = exclude_from_schema - return WrappedAPIView.as_view() + return decorator diff --git a/rest_framework/schemas/generators.py b/rest_framework/schemas/generators.py index 8794c9967..116ca1819 100644 --- a/rest_framework/schemas/generators.py +++ b/rest_framework/schemas/generators.py @@ -207,14 +207,6 @@ class EndpointEnumerator(object): if not is_api_view(callback): return False # Ignore anything except REST framework views. - if hasattr(callback.cls, 'exclude_from_schema'): - fmt = ("The `{}.exclude_from_schema` attribute is deprecated. " - "Set `schema = None` instead.") - msg = fmt.format(callback.cls.__name__) - warnings.warn(msg, DeprecationWarning) - if getattr(callback.cls, 'exclude_from_schema', False): - return False - if callback.cls.schema is None: return False diff --git a/tests/test_schemas.py b/tests/test_schemas.py index ad2e34a4b..8e097f9f4 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -1032,38 +1032,6 @@ class SchemaGenerationExclusionTests(TestCase): assert should_include == expected - def test_deprecations(self): - with pytest.warns(DeprecationWarning) as record: - @api_view(["GET"], exclude_from_schema=True) - def view(request): - pass - - assert len(record) == 1 - assert str(record[0].message) == ( - "The `exclude_from_schema` argument to `api_view` is deprecated. " - "Use the `schema` decorator instead, passing `None`." - ) - - class OldFashionedExcludedView(APIView): - exclude_from_schema = True - - def get(self, request, *args, **kwargs): - pass - - patterns = [ - url('^excluded-old-fashioned/$', OldFashionedExcludedView.as_view()), - ] - - inspector = EndpointEnumerator(patterns) - with pytest.warns(DeprecationWarning) as record: - inspector.get_api_endpoints() - - assert len(record) == 1 - assert str(record[0].message) == ( - "The `OldFashionedExcludedView.exclude_from_schema` attribute is " - "deprecated. Set `schema = None` instead." - ) - @api_view(["GET"]) def simple_fbv(request):