Skip to content

Commit 7266e87

Browse files
authored
Fix remnants of when check() parameters were reversed (#209)
1 parent 2209d84 commit 7266e87

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/reference/settings.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ Example:
304304
305305
class MySessionChecker:
306306
307-
def check(self, request: Request, response: Response) -> bool:
307+
def check(self, response: Response, request: Request) -> bool:
308308
return bool(response.css(".is_valid"))
309309
310310
@@ -330,7 +330,7 @@ object, for example to read settings:
330330
location = crawler.settings["ZYTE_API_SESSION_LOCATION"]
331331
self.postal_code = location["postalCode"]
332332
333-
def check(self, request: Request, response: Response) -> bool:
333+
def check(self, response: Response, request: Request) -> bool:
334334
return response.css(".postal_code::text").get() == self.postal_code
335335
336336

tests/test_sessions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def closed(self, reason):
652652

653653
class CloseSpiderURLChecker:
654654

655-
def check(self, request: Request, response: Response) -> bool:
655+
def check(self, response: Response, request: Request) -> bool:
656656
if "fail" in request.url:
657657
raise CloseSpider("closed_by_checker")
658658
return True
@@ -829,7 +829,7 @@ def parse(self, response):
829829

830830
class DomainChecker:
831831

832-
def check(self, request: Request, response: Response) -> bool:
832+
def check(self, response: Response, request: Request) -> bool:
833833
domain = urlparse_cached(request).netloc
834834
return "fail" not in domain
835835

0 commit comments

Comments
 (0)