2
2
3
3
import collections .abc as c
4
4
import typing as t
5
- import warnings
6
5
import weakref
7
6
from collections import defaultdict
8
- from contextlib import AbstractContextManager
9
7
from contextlib import contextmanager
10
8
from functools import cached_property
11
9
from inspect import iscoroutinefunction
12
- from weakref import WeakValueDictionary
13
10
14
11
from ._utilities import make_id
15
12
from ._utilities import make_ref
@@ -139,15 +136,6 @@ def connect(self, receiver: F, sender: t.Any = ANY, weak: bool = True) -> F:
139
136
self .disconnect (receiver , sender )
140
137
raise
141
138
142
- if _receiver_connected .receivers and self is not _receiver_connected :
143
- try :
144
- _receiver_connected .send (
145
- self , receiver_arg = receiver , sender_arg = sender , weak_arg = weak
146
- )
147
- except TypeError :
148
- self .disconnect (receiver , sender )
149
- raise
150
-
151
139
return receiver
152
140
153
141
def connect_via (self , sender : t .Any , weak : bool = False ) -> c .Callable [[F ], F ]:
@@ -213,24 +201,6 @@ def muted(self) -> c.Generator[None, None, None]:
213
201
finally :
214
202
self .is_muted = False
215
203
216
- def temporarily_connected_to (
217
- self , receiver : c .Callable [..., t .Any ], sender : t .Any = ANY
218
- ) -> AbstractContextManager [None ]:
219
- """Deprecated alias for :meth:`connected_to`.
220
-
221
- .. deprecated:: 1.1
222
- Renamed to ``connected_to``. Will be removed in Blinker 1.9.
223
-
224
- .. versionadded:: 0.9
225
- """
226
- warnings .warn (
227
- "'temporarily_connected_to' is renamed to 'connected_to'. The old name is"
228
- " deprecated and will be removed in Blinker 1.9." ,
229
- DeprecationWarning ,
230
- stacklevel = 2 ,
231
- )
232
- return self .connected_to (receiver , sender )
233
-
234
204
def send (
235
205
self ,
236
206
sender : t .Any | None = None ,
@@ -488,23 +458,6 @@ def _clear_state(self) -> None:
488
458
self ._by_receiver .clear ()
489
459
490
460
491
- _receiver_connected = Signal (
492
- """\
493
- Sent by a :class:`Signal` after a receiver connects.
494
-
495
- :argument: the Signal that was connected to
496
- :keyword receiver_arg: the connected receiver
497
- :keyword sender_arg: the sender to connect to
498
- :keyword weak_arg: true if the connection to receiver_arg is a weak reference
499
-
500
- .. deprecated:: 1.2
501
- Individual signals have their own :attr:`~Signal.receiver_connected` and
502
- :attr:`~Signal.receiver_disconnected` signals with a slightly simplified
503
- call signature. This global signal will be removed in Blinker 1.9.
504
- """
505
- )
506
-
507
-
508
461
class NamedSignal (Signal ):
509
462
"""A named generic notification emitter. The name is not used by the signal
510
463
itself, but matches the key in the :class:`Namespace` that it belongs to.
@@ -551,41 +504,6 @@ def signal(self, name: str, doc: str | None = None) -> NamedSignal:
551
504
return self [name ]
552
505
553
506
554
- class _WeakNamespace (WeakValueDictionary ): # type: ignore[type-arg]
555
- """A weak mapping of names to signals.
556
-
557
- Automatically cleans up unused signals when the last reference goes out
558
- of scope. This namespace implementation provides similar behavior to Blinker
559
- <= 1.2.
560
-
561
- .. deprecated:: 1.3
562
- Will be removed in Blinker 1.9.
563
-
564
- .. versionadded:: 1.3
565
- """
566
-
567
- def __init__ (self ) -> None :
568
- warnings .warn (
569
- "'WeakNamespace' is deprecated and will be removed in Blinker 1.9."
570
- " Use 'Namespace' instead." ,
571
- DeprecationWarning ,
572
- stacklevel = 2 ,
573
- )
574
- super ().__init__ ()
575
-
576
- def signal (self , name : str , doc : str | None = None ) -> NamedSignal :
577
- """Return the :class:`NamedSignal` for the given ``name``, creating it
578
- if required. Repeated calls with the same name return the same signal.
579
-
580
- :param name: The name of the signal.
581
- :param doc: The docstring of the signal.
582
- """
583
- if name not in self :
584
- self [name ] = NamedSignal (name , doc )
585
-
586
- return self [name ] # type: ignore[no-any-return]
587
-
588
-
589
507
default_namespace : Namespace = Namespace ()
590
508
"""A default :class:`Namespace` for creating named signals. :func:`signal`
591
509
creates a :class:`NamedSignal` in this namespace.
@@ -596,26 +514,3 @@ def signal(self, name: str, doc: str | None = None) -> NamedSignal:
596
514
``name``, creating it if required. Repeated calls with the same name return the
597
515
same signal.
598
516
"""
599
-
600
-
601
- def __getattr__ (name : str ) -> t .Any :
602
- if name == "receiver_connected" :
603
- warnings .warn (
604
- "The global 'receiver_connected' signal is deprecated and will be"
605
- " removed in Blinker 1.9. Use 'Signal.receiver_connected' and"
606
- " 'Signal.receiver_disconnected' instead." ,
607
- DeprecationWarning ,
608
- stacklevel = 2 ,
609
- )
610
- return _receiver_connected
611
-
612
- if name == "WeakNamespace" :
613
- warnings .warn (
614
- "'WeakNamespace' is deprecated and will be removed in Blinker 1.9."
615
- " Use 'Namespace' instead." ,
616
- DeprecationWarning ,
617
- stacklevel = 2 ,
618
- )
619
- return _WeakNamespace
620
-
621
- raise AttributeError (name )
0 commit comments