Skip to content

Commit 8c983ec

Browse files
authored
remove previously deprecated code (#172)
1 parent f5915f3 commit 8c983ec

File tree

4 files changed

+10
-149
lines changed

4 files changed

+10
-149
lines changed

CHANGES.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Version 1.9.0
2+
-------------
3+
4+
Unreleased
5+
6+
- Remove previously deprecated ``__version__``, ``receiver_connected``,
7+
``Signal.temporarily_connected_to`` and ``WeakNamespace``. :pr:`172`
8+
9+
110
Version 1.8.2
211
-------------
312

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "blinker"
3-
version = "1.8.2"
3+
version = "1.9.0"
44
description = "Fast, simple object-to-object and broadcast signaling"
55
readme = "README.md"
66
license = { file = "LICENSE.txt" }

src/blinker/__init__.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from __future__ import annotations
22

3-
import typing as t
4-
53
from .base import ANY
64
from .base import default_namespace
75
from .base import NamedSignal
@@ -17,44 +15,3 @@
1715
"Signal",
1816
"signal",
1917
]
20-
21-
22-
def __getattr__(name: str) -> t.Any:
23-
import warnings
24-
25-
if name == "__version__":
26-
import importlib.metadata
27-
28-
warnings.warn(
29-
"The '__version__' attribute is deprecated and will be removed in"
30-
" Blinker 1.9.0. Use feature detection or"
31-
" 'importlib.metadata.version(\"blinker\")' instead.",
32-
DeprecationWarning,
33-
stacklevel=2,
34-
)
35-
return importlib.metadata.version("blinker")
36-
37-
if name == "receiver_connected":
38-
from .base import _receiver_connected
39-
40-
warnings.warn(
41-
"The global 'receiver_connected' signal is deprecated and will be"
42-
" removed in Blinker 1.9. Use 'Signal.receiver_connected' and"
43-
" 'Signal.receiver_disconnected' instead.",
44-
DeprecationWarning,
45-
stacklevel=2,
46-
)
47-
return _receiver_connected
48-
49-
if name == "WeakNamespace":
50-
from .base import _WeakNamespace
51-
52-
warnings.warn(
53-
"'WeakNamespace' is deprecated and will be removed in Blinker 1.9."
54-
" Use 'Namespace' instead.",
55-
DeprecationWarning,
56-
stacklevel=2,
57-
)
58-
return _WeakNamespace
59-
60-
raise AttributeError(name)

src/blinker/base.py

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
import collections.abc as c
44
import typing as t
5-
import warnings
65
import weakref
76
from collections import defaultdict
8-
from contextlib import AbstractContextManager
97
from contextlib import contextmanager
108
from functools import cached_property
119
from inspect import iscoroutinefunction
12-
from weakref import WeakValueDictionary
1310

1411
from ._utilities import make_id
1512
from ._utilities import make_ref
@@ -139,15 +136,6 @@ def connect(self, receiver: F, sender: t.Any = ANY, weak: bool = True) -> F:
139136
self.disconnect(receiver, sender)
140137
raise
141138

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-
151139
return receiver
152140

153141
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]:
213201
finally:
214202
self.is_muted = False
215203

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-
234204
def send(
235205
self,
236206
sender: t.Any | None = None,
@@ -488,23 +458,6 @@ def _clear_state(self) -> None:
488458
self._by_receiver.clear()
489459

490460

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-
508461
class NamedSignal(Signal):
509462
"""A named generic notification emitter. The name is not used by the signal
510463
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:
551504
return self[name]
552505

553506

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-
589507
default_namespace: Namespace = Namespace()
590508
"""A default :class:`Namespace` for creating named signals. :func:`signal`
591509
creates a :class:`NamedSignal` in this namespace.
@@ -596,26 +514,3 @@ def signal(self, name: str, doc: str | None = None) -> NamedSignal:
596514
``name``, creating it if required. Repeated calls with the same name return the
597515
same signal.
598516
"""
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

Comments
 (0)