Skip to content

fix(python): declare read-scan methods in the datafusion type stub - #918

Merged
JingsongLi merged 1 commit into
apache:mainfrom
jackylee-ch:fix/python-read-type-stubs
Sep 24, 2026
Merged

JingsongLi merged 1 commit into
apache:mainfrom
jackylee-ch:fix/python-read-type-stubs

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

ReadBuilder.with_nested_projection, TableScan.with_chunk_shuffle and TableScan.with_shard are implemented #[pymethods] (and exercised in tests/test_read.py), but datafusion.pyi never declared them — #887 and #890 added the methods and skipped the stub. The package ships py.typed, so a typed caller gets a mypy/pyright "no attribute" error and no completion for API that works. Declares the three with signatures matching the impl.

`ReadBuilder.with_nested_projection`, `TableScan.with_chunk_shuffle` and
`TableScan.with_shard` are implemented `#[pymethods]` and exercised in
`tests/test_read.py`, but `datafusion.pyi` never declared them. The package
ships `py.typed`, so the stub is the type contract: mypy/pyright reject these
calls with "no attribute" and offer no completion, even though they work.

The methods were added in apache#887 and apache#890; the stub was just not updated.

@JingsongLi JingsongLi 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.

Reviewed head 0711b144. This has end-to-end value for typed Python callers: the three methods already exist in the PyO3 implementation and are exercised in tests/test_read.py, while the published py.typed stub omitted them. The added argument and fluent return types match the native signatures (String/u64, usize/usize, and Vec<Vec<String>> respectively). I found no actionable regression.

Validation: parsed the full .pyi with Python's AST and asserted all three method names, parameters, annotations, and return types; git diff --check passed; head CI is green. A mypy/pyright executable and a built Python extension are not present in this checkout, so I did not claim a live type-checker or Python runtime run for this stub-only change.

@JingsongLi
JingsongLi merged commit 544ea70 into apache:main Sep 24, 2026
14 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