Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose the default signal namespace #145

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Unreleased
signal and specify that it will be removed in the next version.
- Greatly simplify how the library uses weakrefs. This is a significant change
internally but should not affect any public API. :pr:`144`
- Expose the namespace used by ``signal()`` as ``default_namespace``.
:pr:`145`


Version 1.7.0
Expand Down
4 changes: 3 additions & 1 deletion src/blinker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import typing as t

from .base import ANY
from .base import default_namespace
from .base import NamedSignal
from .base import Namespace
from .base import Signal
Expand All @@ -11,11 +12,12 @@

__all__ = [
"ANY",
"default_namespace",
"NamedSignal",
"Namespace",
"Signal",
"WeakNamespace",
"signal",
"WeakNamespace",
]


Expand Down
10 changes: 9 additions & 1 deletion src/blinker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,15 @@ def signal(self, name: str, doc: str | None = None) -> NamedSignal:
return result # type: ignore[no-any-return]


signal = Namespace().signal
default_namespace = Namespace()
"""A default namespace for creating named signals. :func:`signal` creates a
signal in this namespace.
"""

signal = default_namespace.signal
"""Create a named signal in :data:`default_namespace`. Repeated calls with
the same name will return the same signal.
"""


def __getattr__(name: str) -> t.Any:
Expand Down