Skip to content

[hnswlib] Spelling bugfix in hnswlib.Index.init_index - #16381

Merged
srittau merged 1 commit into
python:mainfrom
matulni:fix-typing_hnswlib
Sep 10, 2026
Merged

[hnswlib] Spelling bugfix in hnswlib.Index.init_index#16381
srittau merged 1 commit into
python:mainfrom
matulni:fix-typing_hnswlib

Conversation

@matulni

@matulni matulni commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

This commit proposes a spelling bug-fix in the hnswlib stubs.

Issue description

Consider the following script (minimal_example.py):

# minimal_example.py
import hnswlib

index = hnswlib.Index(space="l2", dim=4)
index.init_index(
            max_elements=1000,
            ef_construction=200,
            M=6,
            allow_replace_deleted=True)

Executing

uv run python minimal_example.py

runs without problems.

Executing

uv run mypy minimal_example.py

raises

minimal_example.py:4: error: Unexpected keyword argument "allow_replace_deleted" for "init_index" of "Index"; did you mean "allow_replace_delete"?  [call-arg]
minimal_example.py:4: note: "init_index" defined in "hnswlib"
Found 1 error in 1 file (checked 1 source file)

Running

uv run pyright minimal_example.py 

raises

minimal_example.py
minimal_example.py:8:13 - error: No parameter named "allow_replace_deleted" (reportCallIssue)
1 error, 0 warnings, 0 informations

Similar typo is found in load_index:

import hnswlib

index = hnswlib.Index(space="l2", dim=4)
print(index.load_index.__doc__)
load_index(self: hnswlib.Index, path_to_index: str, max_elements: typing.SupportsInt | typing.SupportsIndex = 0, allow_replace_deleted: bool = False) -> None

Enviroment

To reproduce the issue, employ the following pyproject.toml:

[project]
name = "hnswlib-typing"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = [
    "hnswlib>=0.8.0",
    "mypy>=2.3.1",
    "pyright>=1.1.414",
    "types-hnswlib>=0.8.0.20260827",
]

Additional information:

Python: 3.13.5 | packaged by Anaconda, Inc. | (main, Jun 12 2025, 11:23:37) [Clang 14.0.6 ]
OS: macOS-26.5.1-arm64-arm-64bit-Mach-O
macOS: 26.5.1
Machine: arm64
Processor: arm

@matulni matulni changed the title [bugfix] Spelling bug in hnswlib stubs [hnswlib] Spelling bugfix in hnswlib.Index.init_index Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@donbarbos donbarbos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@srittau
srittau merged commit bcb5ba6 into python:main Sep 10, 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.

3 participants