diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py index 9d3c628f66..d690dc5d56 100644 --- a/django/utils/deprecation.py +++ b/django/utils/deprecation.py @@ -83,16 +83,6 @@ class RenameMethodsBase(type): 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 diff --git a/tests/deprecation/tests.py b/tests/deprecation/tests.py index b64691eb55..5548e90285 100644 --- a/tests/deprecation/tests.py +++ b/tests/deprecation/tests.py @@ -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): @@ -166,14 +161,3 @@ class RenameMethodsTests(SimpleTestCase): 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)