Skip to content

Commit 7a764a6

Browse files
committed
Delay CoreAPI deprecation until DRF 3.18
1 parent ad0fea0 commit 7a764a6

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

rest_framework/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
DJANGO_DURATION_FORMAT = 'django'
2525

2626

27-
class RemovedInDRF317Warning(PendingDeprecationWarning):
27+
class RemovedInDRF318Warning(DeprecationWarning):
2828
pass

rest_framework/filters.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from django.utils.text import smart_split, unescape_string_literal
1515
from django.utils.translation import gettext_lazy as _
1616

17-
from rest_framework import RemovedInDRF317Warning
17+
from rest_framework import RemovedInDRF318Warning
1818
from rest_framework.compat import coreapi, coreschema
1919
from rest_framework.fields import CharField
2020
from rest_framework.settings import api_settings
@@ -51,7 +51,7 @@ def filter_queryset(self, request, queryset, view):
5151
def get_schema_fields(self, view):
5252
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
5353
if coreapi is not None:
54-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
54+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
5555
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
5656
return []
5757

@@ -189,7 +189,7 @@ def to_html(self, request, queryset, view):
189189
def get_schema_fields(self, view):
190190
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
191191
if coreapi is not None:
192-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
192+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
193193
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
194194
return [
195195
coreapi.Field(
@@ -351,7 +351,7 @@ def to_html(self, request, queryset, view):
351351
def get_schema_fields(self, view):
352352
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
353353
if coreapi is not None:
354-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
354+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
355355
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
356356
return [
357357
coreapi.Field(

rest_framework/pagination.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from django.utils.encoding import force_str
1616
from django.utils.translation import gettext_lazy as _
1717

18-
from rest_framework import RemovedInDRF317Warning
18+
from rest_framework import RemovedInDRF318Warning
1919
from rest_framework.compat import coreapi, coreschema
2020
from rest_framework.exceptions import NotFound
2121
from rest_framework.response import Response
@@ -154,7 +154,7 @@ def get_results(self, data):
154154
def get_schema_fields(self, view):
155155
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
156156
if coreapi is not None:
157-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
157+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
158158
return []
159159

160160
def get_schema_operation_parameters(self, view):
@@ -316,7 +316,7 @@ def to_html(self):
316316
def get_schema_fields(self, view):
317317
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
318318
if coreapi is not None:
319-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
319+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
320320
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
321321
fields = [
322322
coreapi.Field(
@@ -533,7 +533,7 @@ def get_count(self, queryset):
533533
def get_schema_fields(self, view):
534534
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
535535
if coreapi is not None:
536-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
536+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
537537
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
538538
return [
539539
coreapi.Field(
@@ -936,7 +936,7 @@ def to_html(self):
936936
def get_schema_fields(self, view):
937937
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
938938
if coreapi is not None:
939-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
939+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
940940
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
941941
fields = [
942942
coreapi.Field(

rest_framework/schemas/coreapi.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.db import models
66
from django.utils.encoding import force_str
77

8-
from rest_framework import RemovedInDRF317Warning, exceptions, serializers
8+
from rest_framework import RemovedInDRF318Warning, exceptions, serializers
99
from rest_framework.compat import coreapi, coreschema, uritemplate
1010
from rest_framework.settings import api_settings
1111

@@ -119,7 +119,7 @@ class SchemaGenerator(BaseSchemaGenerator):
119119
def __init__(self, title=None, url=None, description=None, patterns=None, urlconf=None, version=None):
120120
assert coreapi, '`coreapi` must be installed for schema support.'
121121
if coreapi is not None:
122-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
122+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
123123
assert coreschema, '`coreschema` must be installed for schema support.'
124124

125125
super().__init__(title, url, description, patterns, urlconf)
@@ -354,7 +354,7 @@ def __init__(self, manual_fields=None):
354354
"""
355355
super().__init__()
356356
if coreapi is not None:
357-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
357+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
358358

359359
if manual_fields is None:
360360
manual_fields = []
@@ -598,7 +598,7 @@ def __init__(self, fields, description='', encoding=None):
598598
"""
599599
super().__init__()
600600
if coreapi is not None:
601-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
601+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
602602

603603
assert all(isinstance(f, coreapi.Field) for f in fields), "`fields` must be a list of coreapi.Field instances"
604604
self._fields = fields
@@ -622,5 +622,5 @@ def get_link(self, path, method, base_url):
622622
def is_enabled():
623623
"""Is CoreAPI Mode enabled?"""
624624
if coreapi is not None:
625-
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
625+
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
626626
return issubclass(api_settings.DEFAULT_SCHEMA_CLASS, AutoSchema)

tests/schemas/test_coreapi.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.urls import include, path
88

99
from rest_framework import (
10-
RemovedInDRF317Warning, filters, generics, pagination, permissions,
10+
RemovedInDRF318Warning, filters, generics, pagination, permissions,
1111
serializers
1212
)
1313
from rest_framework.compat import coreapi, coreschema
@@ -1445,42 +1445,42 @@ def test_schema_handles_exception():
14451445

14461446
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
14471447
def test_coreapi_deprecation():
1448-
with pytest.warns(RemovedInDRF317Warning):
1448+
with pytest.warns(RemovedInDRF318Warning):
14491449
SchemaGenerator()
14501450

1451-
with pytest.warns(RemovedInDRF317Warning):
1451+
with pytest.warns(RemovedInDRF318Warning):
14521452
AutoSchema()
14531453

1454-
with pytest.warns(RemovedInDRF317Warning):
1454+
with pytest.warns(RemovedInDRF318Warning):
14551455
ManualSchema({})
14561456

1457-
with pytest.warns(RemovedInDRF317Warning):
1457+
with pytest.warns(RemovedInDRF318Warning):
14581458
deprecated_filter = OrderingFilter()
14591459
deprecated_filter.get_schema_fields({})
14601460

1461-
with pytest.warns(RemovedInDRF317Warning):
1461+
with pytest.warns(RemovedInDRF318Warning):
14621462
deprecated_filter = BaseFilterBackend()
14631463
deprecated_filter.get_schema_fields({})
14641464

1465-
with pytest.warns(RemovedInDRF317Warning):
1465+
with pytest.warns(RemovedInDRF318Warning):
14661466
deprecated_filter = SearchFilter()
14671467
deprecated_filter.get_schema_fields({})
14681468

1469-
with pytest.warns(RemovedInDRF317Warning):
1469+
with pytest.warns(RemovedInDRF318Warning):
14701470
paginator = BasePagination()
14711471
paginator.get_schema_fields({})
14721472

1473-
with pytest.warns(RemovedInDRF317Warning):
1473+
with pytest.warns(RemovedInDRF318Warning):
14741474
paginator = PageNumberPagination()
14751475
paginator.get_schema_fields({})
14761476

1477-
with pytest.warns(RemovedInDRF317Warning):
1477+
with pytest.warns(RemovedInDRF318Warning):
14781478
paginator = LimitOffsetPagination()
14791479
paginator.get_schema_fields({})
14801480

1481-
with pytest.warns(RemovedInDRF317Warning):
1481+
with pytest.warns(RemovedInDRF318Warning):
14821482
paginator = CursorPagination()
14831483
paginator.get_schema_fields({})
14841484

1485-
with pytest.warns(RemovedInDRF317Warning):
1485+
with pytest.warns(RemovedInDRF318Warning):
14861486
is_enabled()

0 commit comments

Comments
 (0)