Skip to content

[hnswlib] Fix Index.get_items return types - #16578

Merged
srittau merged 1 commit into
python:mainfrom
Blacksujit:hnswlib-get-items-return-type
Oct 20, 2026
Merged

srittau merged 1 commit into
python:mainfrom
Blacksujit:hnswlib-get-items-return-type

Conversation

@Blacksujit

Copy link
Copy Markdown
Contributor

Index.get_items defaults to return_type="numpy", but the first overload gave both parameters a default and matched return_type="list", so a plain index.get_items(ids) was typed as list[float] instead of a NumPy array; the list form also returns one list per requested id, not a flat list of floats.

This reorders the overloads so the default call returns NDArray[np.float32], makes return_type="list" required in the list overloads (positional or keyword), and types the list result as list[list[float]].

Upstream source (v0.8.0): https://github.com/nmslib/hnswlib/blob/v0.8.0/python_bindings/bindings.cpp#L307-L338 (binding with return_type = "numpy" default at L937); docs: https://github.com/nmslib/hnswlib/blob/v0.8.0/README.md

AI agent used: Claude Code (claude-opus-5-5).

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau
srittau merged commit eeaa6cb into python:main Oct 20, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants