Fix typing of inlineCallbacks-decorated functions.

This commit is contained in:
Andrey Rakhmatullin 2023-01-25 22:31:12 +04:00
parent 232aab53b3
commit 764a9d47bb
2 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@ For more information see docs/topics/architecture.rst
import logging
import warnings
from time import time
from typing import Callable, Iterable, Iterator, Optional, Set, Union
from typing import Any, Callable, Generator, Iterable, Iterator, Optional, Set, Union
from twisted.internet.defer import Deferred, inlineCallbacks, succeed
from twisted.internet.task import LoopingCall
@ -96,7 +96,7 @@ class ExecutionEngine:
return scheduler_cls
@inlineCallbacks
def start(self) -> Deferred:
def start(self) -> Generator[Deferred, Any, None]:
if self.running:
raise RuntimeError("Engine already running")
self.start_time = time()
@ -109,7 +109,7 @@ class ExecutionEngine:
"""Gracefully stop the execution engine"""
@inlineCallbacks
def _finish_stopping_engine(_) -> Deferred:
def _finish_stopping_engine(_) -> Generator[Deferred, Any, None]:
yield self.signals.send_catch_log_deferred(signal=signals.engine_stopped)
self._closewait.callback(None)

View File

@ -182,7 +182,7 @@ class SpiderMiddlewareManager(MiddlewareManager):
spider: Spider,
result: Union[Iterable, AsyncIterable],
start_index: int = 0,
) -> Deferred:
) -> Generator[Deferred, Any, Union[MutableChain, MutableAsyncChain]]:
# items in this iterable do not need to go through the process_spider_output
# chain, they went through it already from the process_spider_exception method
recovered: Union[MutableChain, MutableAsyncChain]