From ed7e01a58b942427ef8761a43776d74ffc0c1a0d Mon Sep 17 00:00:00 2001 From: Prashanth Rao <35005448+prrao87@users.noreply.github.com> Date: Fri, 20 Mar 2026 12:34:42 -0400 Subject: [PATCH] docs: fix rendering issues with missing index types in API docs (#3143) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem The generated Python API docs for `lancedb.table.IndexStatistics.index_type` were misleading because mkdocstrings renders that field’s type annotation directly, and the existing `Literal[...]` listed only a subset of the actual canonical SDK index type strings. Current (missing index types): image ## Fix - Update the `IndexStatistics.index_type` annotation in `python/python/lancedb/table.py` to include the full supported set of canonical values, so the generated docs show all valid index_type strings inline. - Add a small regression test in `python/python/tests/test_index.py` to ensure the docs-facing annotation does not drift silently again in case we add a new index/quantization type in the future. - Bumps mkdocs and material theme versions to mkdocs 1.6 to allow access to more features like hooks After fix (all index types are included and tested for in the annotations): image --- docs/requirements.txt | 6 +++--- python/python/lancedb/table.py | 11 ++++++++++- python/python/tests/test_index.py | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 60d3b5e3e..e5f3867cb 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,8 +1,8 @@ -mkdocs==1.5.3 +mkdocs==1.6.1 mkdocs-jupyter==0.24.1 -mkdocs-material==9.5.3 +mkdocs-material==9.6.23 mkdocs-autorefs>=0.5,<=1.0 -mkdocstrings[python]==0.25.2 +mkdocstrings[python]>=0.24,<1.0 griffe>=0.40,<1.0 mkdocs-render-swagger-plugin>=0.1.0 pydantic>=2.0,<3.0 diff --git a/python/python/lancedb/table.py b/python/python/lancedb/table.py index 0f0acaea0..e4bf24577 100644 --- a/python/python/lancedb/table.py +++ b/python/python/lancedb/table.py @@ -4751,7 +4751,16 @@ class IndexStatistics: num_indexed_rows: int num_unindexed_rows: int index_type: Literal[ - "IVF_PQ", "IVF_HNSW_PQ", "IVF_HNSW_SQ", "FTS", "BTREE", "BITMAP", "LABEL_LIST" + "IVF_FLAT", + "IVF_SQ", + "IVF_PQ", + "IVF_RQ", + "IVF_HNSW_SQ", + "IVF_HNSW_PQ", + "FTS", + "BTREE", + "BITMAP", + "LABEL_LIST", ] distance_type: Optional[Literal["l2", "cosine", "dot"]] = None num_indices: Optional[int] = None diff --git a/python/python/tests/test_index.py b/python/python/tests/test_index.py index b4097a8f0..8dfa55a77 100644 --- a/python/python/tests/test_index.py +++ b/python/python/tests/test_index.py @@ -3,6 +3,7 @@ from datetime import timedelta import random +from typing import get_args, get_type_hints import pyarrow as pa import pytest @@ -22,6 +23,7 @@ from lancedb.index import ( HnswSq, FTS, ) +from lancedb.table import IndexStatistics @pytest_asyncio.fixture @@ -283,3 +285,23 @@ async def test_create_index_with_binary_vectors(binary_table: AsyncTable): for v in range(256): res = await binary_table.query().nearest_to([v] * 128).to_arrow() assert res["id"][0].as_py() == v + + +def test_index_statistics_index_type_lists_all_supported_values(): + expected_index_types = { + "IVF_FLAT", + "IVF_SQ", + "IVF_PQ", + "IVF_RQ", + "IVF_HNSW_SQ", + "IVF_HNSW_PQ", + "FTS", + "BTREE", + "BITMAP", + "LABEL_LIST", + } + + assert ( + set(get_args(get_type_hints(IndexStatistics)["index_type"])) + == expected_index_types + )