Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ max_supported_python = "3.14"
[tool.pytest.ini_options]
addopts = "--tb=short --strict-markers -ra"
testpaths = [ "tests" ]
filterwarnings = [ "ignore:CoreAPI compatibility is deprecated*:rest_framework.RemovedInDRF317Warning" ]
filterwarnings = [ "ignore:CoreAPI compatibility is deprecated*:rest_framework.RemovedInDRF318Warning" ]

[tool.coverage.run]
# NOTE: source is ignored with pytest-cov (but uses the same).
Expand Down
2 changes: 1 addition & 1 deletion rest_framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
DJANGO_DURATION_FORMAT = 'django'


class RemovedInDRF317Warning(PendingDeprecationWarning):
class RemovedInDRF318Warning(DeprecationWarning):
pass
8 changes: 4 additions & 4 deletions rest_framework/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from django.utils.text import smart_split, unescape_string_literal
from django.utils.translation import gettext_lazy as _

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

Expand Down Expand Up @@ -189,7 +189,7 @@ def to_html(self, request, queryset, view):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return [
coreapi.Field(
Expand Down Expand Up @@ -351,7 +351,7 @@ def to_html(self, request, queryset, view):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return [
coreapi.Field(
Expand Down
10 changes: 5 additions & 5 deletions rest_framework/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _

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

def get_schema_operation_parameters(self, view):
Expand Down Expand Up @@ -316,7 +316,7 @@ def to_html(self):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
fields = [
coreapi.Field(
Expand Down Expand Up @@ -533,7 +533,7 @@ def get_count(self, queryset):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return [
coreapi.Field(
Expand Down Expand Up @@ -936,7 +936,7 @@ def to_html(self):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
fields = [
coreapi.Field(
Expand Down
10 changes: 5 additions & 5 deletions rest_framework/schemas/coreapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.db import models
from django.utils.encoding import force_str

from rest_framework import RemovedInDRF317Warning, exceptions, serializers
from rest_framework import RemovedInDRF318Warning, exceptions, serializers
from rest_framework.compat import coreapi, coreschema, uritemplate
from rest_framework.settings import api_settings

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

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

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

assert all(isinstance(f, coreapi.Field) for f in fields), "`fields` must be a list of coreapi.Field instances"
self._fields = fields
Expand All @@ -622,5 +622,5 @@ def get_link(self, path, method, base_url):
def is_enabled():
"""Is CoreAPI Mode enabled?"""
if coreapi is not None:
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.18', RemovedInDRF318Warning)
return issubclass(api_settings.DEFAULT_SCHEMA_CLASS, AutoSchema)
24 changes: 12 additions & 12 deletions tests/schemas/test_coreapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.urls import include, path

from rest_framework import (
RemovedInDRF317Warning, filters, generics, pagination, permissions,
RemovedInDRF318Warning, filters, generics, pagination, permissions,
serializers
)
from rest_framework.compat import coreapi, coreschema
Expand Down Expand Up @@ -1445,42 +1445,42 @@ def test_schema_handles_exception():

@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
def test_coreapi_deprecation():
with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
SchemaGenerator()

with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
AutoSchema()

with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
ManualSchema({})

with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
deprecated_filter = OrderingFilter()
deprecated_filter.get_schema_fields({})

with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
deprecated_filter = BaseFilterBackend()
deprecated_filter.get_schema_fields({})

with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
deprecated_filter = SearchFilter()
deprecated_filter.get_schema_fields({})

with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
paginator = BasePagination()
paginator.get_schema_fields({})

with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
paginator = PageNumberPagination()
paginator.get_schema_fields({})

with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
paginator = LimitOffsetPagination()
paginator.get_schema_fields({})

with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
paginator = CursorPagination()
paginator.get_schema_fields({})

with pytest.warns(RemovedInDRF317Warning):
with pytest.warns(RemovedInDRF318Warning):
is_enabled()