|
4 | 4 | import contextlib |
5 | 5 | import inspect |
6 | 6 | from collections.abc import Sequence |
7 | | -from typing import Any, Callable, Literal, overload |
| 7 | +from typing import Any, Callable, Literal, cast, overload |
8 | 8 |
|
9 | 9 | from anyio import create_task_group |
10 | 10 |
|
@@ -119,7 +119,7 @@ def __init__( |
119 | 119 |
|
120 | 120 | if not (stop_propagation and prevent_default): |
121 | 121 | with contextlib.suppress(Exception): |
122 | | - func_to_inspect = function |
| 122 | + func_to_inspect = cast(Any, function) |
123 | 123 | while hasattr(func_to_inspect, "__wrapped__"): |
124 | 124 | func_to_inspect = func_to_inspect.__wrapped__ |
125 | 125 |
|
@@ -172,21 +172,21 @@ def to_event_handler_function( |
172 | 172 | async def wrapper(data: Sequence[Any]) -> None: |
173 | 173 | await function(*data) |
174 | 174 |
|
175 | | - wrapper.__wrapped__ = function |
| 175 | + cast(Any, wrapper).__wrapped__ = function |
176 | 176 |
|
177 | 177 | else: |
178 | 178 |
|
179 | 179 | async def wrapper(data: Sequence[Any]) -> None: |
180 | 180 | function(*data) |
181 | 181 |
|
182 | | - wrapper.__wrapped__ = function |
| 182 | + cast(Any, wrapper).__wrapped__ = function |
183 | 183 | return wrapper |
184 | 184 | elif not asyncio.iscoroutinefunction(function): |
185 | 185 |
|
186 | 186 | async def wrapper(data: Sequence[Any]) -> None: |
187 | 187 | function(data) |
188 | 188 |
|
189 | | - wrapper.__wrapped__ = function |
| 189 | + cast(Any, wrapper).__wrapped__ = function |
190 | 190 | return wrapper |
191 | 191 | else: |
192 | 192 | return function |
|
0 commit comments