mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-18 12:12:19 +03:00
Bumped removal to DRF315
This commit is contained in:
parent
560e581003
commit
73f3e0a6b7
|
@ -35,3 +35,7 @@ class RemovedInDRF313Warning(DeprecationWarning):
|
||||||
|
|
||||||
class RemovedInDRF314Warning(PendingDeprecationWarning):
|
class RemovedInDRF314Warning(PendingDeprecationWarning):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class RemovedInDRF315Warning(PendingDeprecationWarning):
|
||||||
|
pass
|
||||||
|
|
|
@ -13,7 +13,7 @@ from django.template import loader
|
||||||
from django.utils.encoding import force_str
|
from django.utils.encoding import force_str
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from rest_framework import RemovedInDRF314Warning
|
from rest_framework import RemovedInDRF315Warning
|
||||||
from rest_framework.compat import coreapi, coreschema, distinct
|
from rest_framework.compat import coreapi, coreschema, distinct
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class BaseFilterBackend:
|
||||||
def get_schema_fields(self, view):
|
def get_schema_fields(self, view):
|
||||||
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ class SearchFilter(BaseFilterBackend):
|
||||||
def get_schema_fields(self, view):
|
def get_schema_fields(self, view):
|
||||||
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
||||||
return [
|
return [
|
||||||
coreapi.Field(
|
coreapi.Field(
|
||||||
|
@ -303,7 +303,7 @@ class OrderingFilter(BaseFilterBackend):
|
||||||
def get_schema_fields(self, view):
|
def get_schema_fields(self, view):
|
||||||
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
||||||
return [
|
return [
|
||||||
coreapi.Field(
|
coreapi.Field(
|
||||||
|
|
|
@ -13,7 +13,7 @@ from django.template import loader
|
||||||
from django.utils.encoding import force_str
|
from django.utils.encoding import force_str
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from rest_framework import RemovedInDRF314Warning
|
from rest_framework import RemovedInDRF315Warning
|
||||||
from rest_framework.compat import coreapi, coreschema
|
from rest_framework.compat import coreapi, coreschema
|
||||||
from rest_framework.exceptions import NotFound
|
from rest_framework.exceptions import NotFound
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
@ -152,7 +152,7 @@ class BasePagination:
|
||||||
def get_schema_fields(self, view):
|
def get_schema_fields(self, view):
|
||||||
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_schema_operation_parameters(self, view):
|
def get_schema_operation_parameters(self, view):
|
||||||
|
@ -312,7 +312,7 @@ class PageNumberPagination(BasePagination):
|
||||||
def get_schema_fields(self, view):
|
def get_schema_fields(self, view):
|
||||||
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
||||||
fields = [
|
fields = [
|
||||||
coreapi.Field(
|
coreapi.Field(
|
||||||
|
@ -532,7 +532,7 @@ class LimitOffsetPagination(BasePagination):
|
||||||
def get_schema_fields(self, view):
|
def get_schema_fields(self, view):
|
||||||
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
||||||
return [
|
return [
|
||||||
coreapi.Field(
|
coreapi.Field(
|
||||||
|
@ -933,7 +933,7 @@ class CursorPagination(BasePagination):
|
||||||
def get_schema_fields(self, view):
|
def get_schema_fields(self, view):
|
||||||
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
|
||||||
fields = [
|
fields = [
|
||||||
coreapi.Field(
|
coreapi.Field(
|
||||||
|
|
|
@ -5,7 +5,7 @@ from urllib import parse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import force_str
|
from django.utils.encoding import force_str
|
||||||
|
|
||||||
from rest_framework import RemovedInDRF314Warning, exceptions, serializers
|
from rest_framework import RemovedInDRF315Warning, exceptions, serializers
|
||||||
from rest_framework.compat import coreapi, coreschema, uritemplate
|
from rest_framework.compat import coreapi, coreschema, uritemplate
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class SchemaGenerator(BaseSchemaGenerator):
|
||||||
def __init__(self, title=None, url=None, description=None, patterns=None, urlconf=None, version=None):
|
def __init__(self, title=None, url=None, description=None, patterns=None, urlconf=None, version=None):
|
||||||
assert coreapi, '`coreapi` must be installed for schema support.'
|
assert coreapi, '`coreapi` must be installed for schema support.'
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
assert coreschema, '`coreschema` must be installed for schema support.'
|
assert coreschema, '`coreschema` must be installed for schema support.'
|
||||||
|
|
||||||
super(SchemaGenerator, self).__init__(title, url, description, patterns, urlconf)
|
super(SchemaGenerator, self).__init__(title, url, description, patterns, urlconf)
|
||||||
|
@ -350,7 +350,7 @@ class AutoSchema(ViewInspector):
|
||||||
"""
|
"""
|
||||||
super(AutoSchema, self).__init__()
|
super(AutoSchema, self).__init__()
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
if manual_fields is None:
|
if manual_fields is None:
|
||||||
manual_fields = []
|
manual_fields = []
|
||||||
self._manual_fields = manual_fields
|
self._manual_fields = manual_fields
|
||||||
|
@ -593,7 +593,7 @@ class ManualSchema(ViewInspector):
|
||||||
"""
|
"""
|
||||||
super(ManualSchema, self).__init__()
|
super(ManualSchema, self).__init__()
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
assert all(isinstance(f, coreapi.Field) for f in fields), "`fields` must be a list of coreapi.Field instances"
|
assert all(isinstance(f, coreapi.Field) for f in fields), "`fields` must be a list of coreapi.Field instances"
|
||||||
self._fields = fields
|
self._fields = fields
|
||||||
self._description = description
|
self._description = description
|
||||||
|
@ -616,5 +616,5 @@ class ManualSchema(ViewInspector):
|
||||||
def is_enabled():
|
def is_enabled():
|
||||||
"""Is CoreAPI Mode enabled?"""
|
"""Is CoreAPI Mode enabled?"""
|
||||||
if coreapi is not None:
|
if coreapi is not None:
|
||||||
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.14', RemovedInDRF314Warning)
|
warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.15', RemovedInDRF315Warning)
|
||||||
return issubclass(api_settings.DEFAULT_SCHEMA_CLASS, AutoSchema)
|
return issubclass(api_settings.DEFAULT_SCHEMA_CLASS, AutoSchema)
|
||||||
|
|
|
@ -4,7 +4,7 @@ license_file = LICENSE.md
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
addopts=--tb=short --strict -ra
|
addopts=--tb=short --strict -ra
|
||||||
testspath = tests
|
testspath = tests
|
||||||
filterwarnings = ignore:CoreAPI compatibility is deprecated*:rest_framework.RemovedInDRF314Warning
|
filterwarnings = ignore:CoreAPI compatibility is deprecated*:rest_framework.RemovedInDRF315Warning
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore = E501,W504
|
ignore = E501,W504
|
||||||
|
|
|
@ -7,7 +7,7 @@ from django.test import TestCase, override_settings
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
|
|
||||||
from rest_framework import (
|
from rest_framework import (
|
||||||
RemovedInDRF314Warning, filters, generics, pagination, permissions,
|
RemovedInDRF315Warning, filters, generics, pagination, permissions,
|
||||||
serializers
|
serializers
|
||||||
)
|
)
|
||||||
from rest_framework.compat import coreapi, coreschema
|
from rest_framework.compat import coreapi, coreschema
|
||||||
|
@ -1384,42 +1384,42 @@ def test_schema_handles_exception():
|
||||||
|
|
||||||
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||||
def test_coreapi_deprecation():
|
def test_coreapi_deprecation():
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
SchemaGenerator()
|
SchemaGenerator()
|
||||||
|
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
AutoSchema()
|
AutoSchema()
|
||||||
|
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
ManualSchema({})
|
ManualSchema({})
|
||||||
|
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
deprecated_filter = OrderingFilter()
|
deprecated_filter = OrderingFilter()
|
||||||
deprecated_filter.get_schema_fields({})
|
deprecated_filter.get_schema_fields({})
|
||||||
|
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
deprecated_filter = BaseFilterBackend()
|
deprecated_filter = BaseFilterBackend()
|
||||||
deprecated_filter.get_schema_fields({})
|
deprecated_filter.get_schema_fields({})
|
||||||
|
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
deprecated_filter = SearchFilter()
|
deprecated_filter = SearchFilter()
|
||||||
deprecated_filter.get_schema_fields({})
|
deprecated_filter.get_schema_fields({})
|
||||||
|
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
paginator = BasePagination()
|
paginator = BasePagination()
|
||||||
paginator.get_schema_fields({})
|
paginator.get_schema_fields({})
|
||||||
|
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
paginator = PageNumberPagination()
|
paginator = PageNumberPagination()
|
||||||
paginator.get_schema_fields({})
|
paginator.get_schema_fields({})
|
||||||
|
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
paginator = LimitOffsetPagination()
|
paginator = LimitOffsetPagination()
|
||||||
paginator.get_schema_fields({})
|
paginator.get_schema_fields({})
|
||||||
|
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
paginator = CursorPagination()
|
paginator = CursorPagination()
|
||||||
paginator.get_schema_fields({})
|
paginator.get_schema_fields({})
|
||||||
|
|
||||||
with pytest.warns(RemovedInDRF314Warning):
|
with pytest.warns(RemovedInDRF315Warning):
|
||||||
is_enabled()
|
is_enabled()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user