From fa9897282fc571bbac64eaba06433362ad233530 Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Sat, 11 Feb 2023 22:11:30 +0400 Subject: [PATCH] Add a cast to deferred_from_coro, that code path has different typing. --- scrapy/utils/defer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scrapy/utils/defer.py b/scrapy/utils/defer.py index a3bd273e3..d25ebbdf4 100644 --- a/scrapy/utils/defer.py +++ b/scrapy/utils/defer.py @@ -288,7 +288,7 @@ def deferred_from_coro(o) -> Any: if not is_asyncio_reactor_installed(): # wrapping the coroutine directly into a Deferred, this doesn't work correctly with coroutines # that use asyncio, e.g. "await asyncio.sleep(1)" - return ensureDeferred(o) + return ensureDeferred(cast(Coroutine[Deferred, Any, Any], o)) # wrapping the coroutine into a Future and then into a Deferred, this requires AsyncioSelectorReactor event_loop = _get_asyncio_event_loop() return Deferred.fromFuture(asyncio.ensure_future(o, loop=event_loop))