Skip to content

Commit

Permalink
Refs #25466 -- Removed unused DeprecationInstanceCheck.
Browse files Browse the repository at this point in the history
Unused since ff419de.
  • Loading branch information
adamchainz authored and sarahboyce committed Jul 11, 2024
1 parent b2fec1f commit 86e1384
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
10 changes: 0 additions & 10 deletions django/utils/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,6 @@ def __new__(cls, name, bases, attrs):
return new_class


class DeprecationInstanceCheck(type):
def __instancecheck__(self, instance):
warnings.warn(
"`%s` is deprecated, use `%s` instead." % (self.__name__, self.alternative),
self.deprecation_warning,
2,
)
return super().__instancecheck__(instance)


class MiddlewareMixin:
sync_capable = True
async_capable = True
Expand Down
18 changes: 1 addition & 17 deletions tests/deprecation/tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import warnings

from django.test import SimpleTestCase
from django.utils.deprecation import (
DeprecationInstanceCheck,
RemovedAfterNextVersionWarning,
RemovedInNextVersionWarning,
RenameMethodsBase,
)
from django.utils.deprecation import RemovedAfterNextVersionWarning, RenameMethodsBase


class RenameManagerMethods(RenameMethodsBase):
Expand Down Expand Up @@ -166,14 +161,3 @@ def test_removedafternextversionwarning_pending(self):
self.assertTrue(
issubclass(RemovedAfterNextVersionWarning, PendingDeprecationWarning)
)


class DeprecationInstanceCheckTest(SimpleTestCase):
def test_warning(self):
class Manager(metaclass=DeprecationInstanceCheck):
alternative = "fake.path.Foo"
deprecation_warning = RemovedInNextVersionWarning

msg = "`Manager` is deprecated, use `fake.path.Foo` instead."
with self.assertWarnsMessage(RemovedInNextVersionWarning, msg):
isinstance(object, Manager)

0 comments on commit 86e1384

Please sign in to comment.