Skip to content

Commit

Permalink
Make mypy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallaecio committed Nov 29, 2023
1 parent b407ab7 commit 369c97b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions scrapy_zyte_api/_middlewares.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from typing import cast

from scrapy import signals
from scrapy.exceptions import IgnoreRequest
Expand Down Expand Up @@ -83,7 +84,9 @@ def open_spider(self, spider):
"either to True or to a dictionary of extra request fields."
)
from twisted.internet import reactor
from twisted.internet.interfaces import IReactorCore

reactor = cast(IReactorCore, reactor)
reactor.callLater(
0, self._crawler.engine.close_spider, spider, "plugin_conflict"
)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_middlewares.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Any, Dict, cast
from unittest import SkipTest

from packaging.version import Version
Expand Down Expand Up @@ -298,7 +299,7 @@ class SPMSpider(Spider):
"ZYTE_SMARTPROXY_APIKEY": "foo",
**SETTINGS,
}
mws = dict(settings["DOWNLOADER_MIDDLEWARES"])
mws = dict(cast(Dict[Any, int], settings["DOWNLOADER_MIDDLEWARES"]))
mws["scrapy_zyte_smartproxy.ZyteSmartProxyMiddleware"] = 610
settings["DOWNLOADER_MIDDLEWARES"] = mws

Expand Down Expand Up @@ -348,7 +349,7 @@ class CrawleraSpider(Spider):
"CRAWLERA_APIKEY": "foo",
**SETTINGS,
}
mws = dict(settings["DOWNLOADER_MIDDLEWARES"])
mws = dict(cast(Dict[Any, int], settings["DOWNLOADER_MIDDLEWARES"]))
mws["scrapy_crawlera.CrawleraMiddleware"] = 610
settings["DOWNLOADER_MIDDLEWARES"] = mws

Expand Down

0 comments on commit 369c97b

Please sign in to comment.