From 4101f8ac7255b27b24943ad5114bcca97ae7646e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Chaves?= Date: Fri, 17 Jan 2025 08:46:38 +0100 Subject: [PATCH] Solve issues caught by mypy --- zyte_spider_templates/spiders/serp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zyte_spider_templates/spiders/serp.py b/zyte_spider_templates/spiders/serp.py index 767dba8..24ccd35 100644 --- a/zyte_spider_templates/spiders/serp.py +++ b/zyte_spider_templates/spiders/serp.py @@ -347,7 +347,8 @@ def parse_serp( self.args.results_per_page or self._default_results_per_page ) if serp.organicResults and ( - serp.metadata.totalOrganicResults is None + serp.metadata is None + or serp.metadata.totalOrganicResults is None or serp.metadata.totalOrganicResults > next_start ): next_url = add_or_replace_parameter(serp.url, "start", str(next_start)) @@ -358,7 +359,7 @@ def parse_serp( yield serp return - for result in serp.organicResults: + for result in serp.organicResults or []: inject: list[type] = [ITEM_TYPE_CLASSES[self.args.item_type]] if self._custom_attrs_dep: inject.append(self._custom_attrs_dep) # type: ignore[arg-type]