diff --git a/docs/reference/settings.rst b/docs/reference/settings.rst index 220603fd..5cc7aa56 100644 --- a/docs/reference/settings.rst +++ b/docs/reference/settings.rst @@ -304,7 +304,7 @@ Example: class MySessionChecker: - def check(self, request: Request, response: Response) -> bool: + def check(self, response: Response, request: Request) -> bool: return bool(response.css(".is_valid")) @@ -330,7 +330,7 @@ object, for example to read settings: location = crawler.settings["ZYTE_API_SESSION_LOCATION"] self.postal_code = location["postalCode"] - def check(self, request: Request, response: Response) -> bool: + def check(self, response: Response, request: Request) -> bool: return response.css(".postal_code::text").get() == self.postal_code diff --git a/tests/test_sessions.py b/tests/test_sessions.py index de240e06..37e4ebad 100644 --- a/tests/test_sessions.py +++ b/tests/test_sessions.py @@ -652,7 +652,7 @@ def closed(self, reason): class CloseSpiderURLChecker: - def check(self, request: Request, response: Response) -> bool: + def check(self, response: Response, request: Request) -> bool: if "fail" in request.url: raise CloseSpider("closed_by_checker") return True @@ -829,7 +829,7 @@ def parse(self, response): class DomainChecker: - def check(self, request: Request, response: Response) -> bool: + def check(self, response: Response, request: Request) -> bool: domain = urlparse_cached(request).netloc return "fail" not in domain