From e6e48e9243b12854fa16e2c1c27590de320cf777 Mon Sep 17 00:00:00 2001 From: Tim Eccleston Date: Wed, 17 Sep 2025 15:11:34 -0700 Subject: [PATCH 1/2] enforce exact max results in search_entities --- wikibaseintegrator/wbi_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wikibaseintegrator/wbi_helpers.py b/wikibaseintegrator/wbi_helpers.py index f6741407..2720f061 100644 --- a/wikibaseintegrator/wbi_helpers.py +++ b/wikibaseintegrator/wbi_helpers.py @@ -444,7 +444,6 @@ def search_entities(search_string: str, language: str | None = None, strict_lang 'search': search_string, 'language': language, 'type': search_type, - 'limit': 50, 'format': 'json' } @@ -455,7 +454,8 @@ def search_entities(search_string: str, language: str | None = None, strict_lang results = [] while True: - params.update({'continue': cont_count}) + max_page_results = min(50, max_results - cont_count) + params.update({'continue': cont_count, 'limit': max_page_results}) search_results = mediawiki_api_call_helper(data=params, allow_anonymous=allow_anonymous, **kwargs) From 49e655d08bbc470f1d8140ccbc8661a977a2191e Mon Sep 17 00:00:00 2001 From: Myst <1592048+LeMyst@users.noreply.github.com> Date: Thu, 18 Sep 2025 23:44:36 +0200 Subject: [PATCH 2/2] Annotate params variable with type hint Added explicit type annotation to the 'params' dictionary in the search_entities function for improved code clarity and type checking. --- wikibaseintegrator/wbi_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wikibaseintegrator/wbi_helpers.py b/wikibaseintegrator/wbi_helpers.py index 2720f061..d03d3a41 100644 --- a/wikibaseintegrator/wbi_helpers.py +++ b/wikibaseintegrator/wbi_helpers.py @@ -439,7 +439,7 @@ def search_entities(search_string: str, language: str | None = None, strict_lang language = str(language or config['DEFAULT_LANGUAGE']) - params = { + params: dict[str, str | int] = { 'action': 'wbsearchentities', 'search': search_string, 'language': language,