Skip to content

fix(mem_wal): sync MemWAL type stubs with the binding signatures - #9701

Merged
Xuanwo merged 4 commits into
lance-format:mainfrom
zhangyue19921010:fix/python-memwal-type-stubs-new
Oct 23, 2026
Merged

Xuanwo merged 4 commits into
lance-format:mainfrom
zhangyue19921010:fix/python-memwal-type-stubs-new

Conversation

@zhangyue19921010

Copy link
Copy Markdown
Collaborator

Description

The type stubs for the MemWAL classes in lance/lance/__init__.pyi had drifted from the PyO3 signatures, so pyright both rejected valid calls and accepted invalid ones.

Method Stub before Binding
_LsmScanner.limit n required n defaults to None, so limit(offset=10) is valid
_LsmVectorSearchPlanner.plan_search no refine_base_table / overfetch_factor both supported
_LsmVectorSearchPlanner.__init__ no filter filter supported
_ShardWriter.lsm_scanner accepts None takes a list; None raises TypeError at runtime

lance/mem_wal.py is also added to pyright's include list, so future drift in the first two kinds is caught in CI. The last two are not visible through that file: it passes filter via **kwargs and never passes None to lsm_scanner.

No runtime behavior changes.

The stubs for the MemWAL classes had fallen behind the PyO3 signatures:

- `_LsmScanner.limit` required `n`, but the binding defaults it to `None`
  to allow an offset-only limit.
- `_LsmVectorSearchPlanner.plan_search` was missing `refine_base_table`
  and `overfetch_factor`.
- `_LsmVectorSearchPlanner.__init__` was missing `filter`.
- `_ShardWriter.lsm_scanner` accepted `None` for `shard_snapshots`, but
  the binding takes a list and raises `TypeError` on `None`; the empty
  default applies only when the argument is omitted.

pyright rejected the first two in `lance/mem_wal.py`. That file was not in
pyright's include list, which is why the mismatch went unnoticed; it is
added now that it checks clean. The last two do not surface through
`lance/mem_wal.py`, which passes `filter` via `**kwargs` and never passes
`None` to `lsm_scanner`.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added A-python Python bindings A-deps Dependency updates bug Something isn't working labels Oct 3, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 3, 2026
pyright runs before the package is built in CI, so `import lance` in
mem_wal.py resolved to the native stub package `lance/lance`, which has
no `LanceDataset`. Import `LanceDataset` and `LanceSchema` relatively,
matching fragment.py.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 3, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 3, 2026
@zhangyue19921010

zhangyue19921010 commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Hi @jackye1995 and @hamersaw mem_wal related bug fix. Would u mind to take a look? Thanks.
There are several other related PRs for mem_wal. Would greatly appreciate it if you could kindly review them!

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 10, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 10, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 13, 2026

@lance-gatekeeper lance-gatekeeper Bot 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.

✅ Gate recommendation: approve.

The corrected stubs match the existing bindings. Checking the MemWAL wrapper covers its limit and vector-search calls, and its type-only imports retain the intended dataset and schema classes.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 13, 2026
@Xuanwo
Xuanwo merged commit 6f9e457 into lance-format:main Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-deps Dependency updates A-python Python bindings bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants