Skip to content

fix(wiki_tools): return list of result dicts for semantic_search return_json#126

Open
LukasGold wants to merge 2 commits into
mainfrom
dev-fix-semantic_search
Open

fix(wiki_tools): return list of result dicts for semantic_search return_json#126
LukasGold wants to merge 2 commits into
mainfrom
dev-fix-semantic_search

Conversation

@LukasGold

Copy link
Copy Markdown
Contributor

No description provided.

…rn_json

semantic_search with SearchParam.return_json=True previously fed the raw
SMW ask result dicts into the flat-list comprehension, so iterating each
dict yielded its keys and the call returned a useless list like ['query']
instead of the result data.

Skip the flatten when return_json=True and return the list of raw result
dicts (one per query, always a list even for a single query). The default
return_json=False behavior (flat list of page-title fulltext strings) is
unchanged.

Add unit tests covering return_json=True for a single query and a list of
queries, plus return_json=False still returning a flat list of titles.
@LukasGold LukasGold requested a review from simontaurus June 26, 2026 08:29
@LukasGold LukasGold self-assigned this Jun 26, 2026
@LukasGold LukasGold added the bug Something isn't working label Jun 26, 2026
@coveralls

coveralls commented Jun 26, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28228157869

Coverage increased (+0.4%) to 50.975%

Details

  • Coverage increased (+0.4%) from the base build.
  • Patch coverage: 4 uncovered changes across 1 file (20 of 24 lines covered, 83.33%).
  • 2 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
src/osw/wiki_tools.py 24 20 83.33%

Coverage Regressions

2 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
src/osw/wiki_tools.py 2 35.25%

Coverage Stats

Coverage Status
Relevant Lines: 5887
Covered Lines: 3195
Line Coverage: 54.27%
Relevant Branches: 1240
Covered Branches: 438
Branch Coverage: 35.32%
Branches in Coverage %: Yes
Coverage Strength: 3.22 hits per line

💛 - Coveralls

…rn_json

prefix_search with SearchParam.return_json=True returned
result['query']['prefixsearch'] (the page-entry list) and still ran it
through the flat-list comprehension, merging entries across queries into a
single flat list and contradicting the docstring's promise of the full API
response per query.

Mirror the semantic_search behavior: the inner helper now returns the full
raw prefixsearch API response, and the outer function skips the flatten when
return_json=True, returning a list of response dicts (one per query, always a
list even for a single query). The default return_json=False behavior (flat
list of page titles) is unchanged.

Add unit tests covering return_json=True for a single query and a list of
queries, plus return_json=False still returning a flat list of titles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants