Skip to content

Commit

Permalink
simplify type for wrapper arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed May 6, 2024
1 parent 76dcca4 commit 6c15fa8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Version 1.8.2
-------------

Unreleased

- Simplify type for ``_async_wrapper`` and ``_sync_wrapper`` arguments.
:pr:`156`


Version 1.8.1
-------------

Expand Down
21 changes: 8 additions & 13 deletions src/blinker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,7 @@
from ._utilities import Symbol

if t.TYPE_CHECKING:
import typing_extensions as te

F = t.TypeVar("F", bound=c.Callable[..., t.Any])
T = t.TypeVar("T")
P = te.ParamSpec("P")

class PAsyncWrapper(t.Protocol):
def __call__(self, f: c.Callable[P, c.Awaitable[T]]) -> c.Callable[P, T]: ...

class PSyncWrapper(t.Protocol):
def __call__(self, f: c.Callable[P, T]) -> c.Callable[P, c.Awaitable[T]]: ...


ANY = Symbol("ANY")
"""Symbol for "any sender"."""
Expand Down Expand Up @@ -247,7 +236,10 @@ def send(
sender: t.Any | None = None,
/,
*,
_async_wrapper: PAsyncWrapper | None = None,
_async_wrapper: c.Callable[
[c.Callable[..., c.Coroutine[t.Any, t.Any, t.Any]]], c.Callable[..., t.Any]
]
| None = None,
**kwargs: t.Any,
) -> list[tuple[c.Callable[..., t.Any], t.Any]]:
"""Call all receivers that are connected to the given ``sender``
Expand Down Expand Up @@ -295,7 +287,10 @@ async def send_async(
sender: t.Any | None = None,
/,
*,
_sync_wrapper: PSyncWrapper | None = None,
_sync_wrapper: c.Callable[
[c.Callable[..., t.Any]], c.Callable[..., c.Coroutine[t.Any, t.Any, t.Any]]
]
| None = None,
**kwargs: t.Any,
) -> list[tuple[c.Callable[..., t.Any], t.Any]]:
"""Await all receivers that are connected to the given ``sender``
Expand Down

0 comments on commit 6c15fa8

Please sign in to comment.