diff --git a/django/db/models/signals.py b/django/db/models/signals.py index 5047f11743..9f9fbccde3 100644 --- a/django/db/models/signals.py +++ b/django/db/models/signals.py @@ -1,10 +1,8 @@ -import warnings from functools import partial from django.db.models.utils import make_model_tuple from django.dispatch import Signal from django.utils import six -from django.utils.deprecation import RemovedInDjango20Warning class_prepared = Signal(providing_args=["class"]) @@ -32,9 +30,7 @@ class ModelSignal(Signal): weak=weak, dispatch_uid=dispatch_uid, ) - def disconnect(self, receiver=None, sender=None, weak=None, dispatch_uid=None, apps=None): - if weak is not None: - warnings.warn("Passing `weak` to disconnect has no effect.", RemovedInDjango20Warning, stacklevel=2) + def disconnect(self, receiver=None, sender=None, dispatch_uid=None, apps=None): return self._lazy_method( super(ModelSignal, self).disconnect, apps, receiver, sender, dispatch_uid=dispatch_uid ) diff --git a/django/dispatch/dispatcher.py b/django/dispatch/dispatcher.py index 742acd198b..db2f6839f8 100644 --- a/django/dispatch/dispatcher.py +++ b/django/dispatch/dispatcher.py @@ -1,10 +1,8 @@ import sys import threading -import warnings import weakref from django.utils import six -from django.utils.deprecation import RemovedInDjango20Warning from django.utils.inspect import func_accepts_kwargs from django.utils.six.moves import range @@ -126,7 +124,7 @@ class Signal(object): self.receivers.append((lookup_key, receiver)) self.sender_receivers_cache.clear() - def disconnect(self, receiver=None, sender=None, weak=None, dispatch_uid=None): + def disconnect(self, receiver=None, sender=None, dispatch_uid=None): """ Disconnect receiver from sender for signal. @@ -145,8 +143,6 @@ class Signal(object): dispatch_uid the unique identifier of the receiver to disconnect """ - if weak is not None: - warnings.warn("Passing `weak` to disconnect has no effect.", RemovedInDjango20Warning, stacklevel=2) if dispatch_uid: lookup_key = (dispatch_uid, _make_id(sender)) else: diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index 738f488456..ebd8089015 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -233,3 +233,6 @@ These features have reached the end of their deprecation cycle and are removed in Django 2.0. See :ref:`deprecated-features-1.9` and :ref:`deprecated-features-1.10` for details, including how to remove usage of these features. + +* The ``weak`` argument to ``django.dispatch.signals.Signal.disconnect()`` is + removed. diff --git a/docs/topics/signals.txt b/docs/topics/signals.txt index 19c0cd3d33..ad2b66f6df 100644 --- a/docs/topics/signals.txt +++ b/docs/topics/signals.txt @@ -277,8 +277,3 @@ arguments are as described in :meth:`.Signal.connect`. The method returns The ``receiver`` argument indicates the registered receiver to disconnect. It may be ``None`` if ``dispatch_uid`` is used to identify the receiver. - -.. deprecated:: 1.9 - - The ``weak`` argument is deprecated as it has no effect. It will be removed - in Django 2.0. diff --git a/tests/dispatch/test_removedindjango20.py b/tests/dispatch/test_removedindjango20.py deleted file mode 100644 index 9b28cf789d..0000000000 --- a/tests/dispatch/test_removedindjango20.py +++ /dev/null @@ -1,24 +0,0 @@ -import warnings - -from django.dispatch import Signal -from django.test import SimpleTestCase - -a_signal = Signal(providing_args=['val']) - - -def receiver_1_arg(val, **kwargs): - return val - - -class DispatcherTests(SimpleTestCase): - - def test_disconnect_weak_deprecated(self): - a_signal.connect(receiver_1_arg) - with warnings.catch_warnings(record=True) as warns: - warnings.simplefilter('always') - a_signal.disconnect(receiver_1_arg, weak=True) - self.assertEqual(len(warns), 1) - self.assertEqual( - str(warns[0].message), - 'Passing `weak` to disconnect has no effect.', - )