GH-49831: [Python] Withhold annotations from Python wheel until they are complete - #50168
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent downstream type checkers from trusting PyArrow’s currently-incomplete bundled type stubs by withholding the PEP 561 py.typed marker from the built wheel (per GH-49831), while keeping stubs and py.typed in-tree for ongoing CI/type-checking work.
Changes:
- Configure the wheel build to exclude
pyarrow/py.typedviawheel.exclude. - Add explanatory comments documenting the rationale and removal TODO.
325b6ac to
860479a
Compare
| # TODO(GH-49831): Temporarily do not install pyarrow-stubs into wheels. | ||
| # The stubs are incomplete, and some type checkers consume .pyi files even | ||
| # without the py.typed marker. Re-enable this when the stubs are complete. | ||
| # |
There was a problem hiding this comment.
You might wanna look into this repo as a follow up 🎁
There was a problem hiding this comment.
Oooh, if this works we can get rid of quite some logic, thanks!
There was a problem hiding this comment.
Ah great - hope so too!
If it doesn't, it could still be worth opening an issue since it's being actively developed - they might just not have coverage for cython yet
There was a problem hiding this comment.
I tested it and didn't get any docstrings of cythonic symbols, so I opened an issue astral-sh/docstring-adder#184.
dangotbanned
left a comment
There was a problem hiding this comment.
Thanks @rok
AFAICT, this should unblock narwhals-dev/narwhals#3560
Probably best to have someone familiar with your build process look this over, but LGTM
1c4cec9 to
fe246a4
Compare
|
@dangotbanned @raulcd I think this is ready for review. Stubs remain in the repo, they are checked but they are not packed into the wheel. |
dangotbanned
left a comment
There was a problem hiding this comment.
Thanks @rok, I still (#50168 (review)) approve 😉
|
@github-actions crossbow submit wheelcp313 python-sdist |
raulcd
left a comment
There was a problem hiding this comment.
This looks good to me and the wheel validations ensure type hint files are not included anymore.
I am triggering a CI job to ensure all wheel platforms are covered and sdist doesn't fail either. If CI jobs are green I think we can merge.
cc @jorisvandenbossche in case you want to do a quick test from pandas side
| echo "=== (${PYTHON_VERSION}) Building wheel ===" | ||
| export PYARROW_BUNDLE_ARROW_CPP=ON | ||
| export PYARROW_REQUIRE_STUB_DOCSTRINGS=ON | ||
| # TODO(GH-49831): Re-enable when pyarrow-stubs are shipped in wheels again. |
There was a problem hiding this comment.
minor nit, this will be done as part of:
Should we reference the issue where this has to be done? might be easier when we are grepping/searching?
|
Revision: 5483c2f Submitted crossbow builds: ursacomputing/crossbow @ actions-0bfec31cfa |
5483c2f to
9987aed
Compare
|
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 889141a. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
* Apply dependabot dependency updates Batches the applicable open dependabot bumps into one commit so that pyproject.toml and uv.lock stay consistent: - ruff 0.15.20 -> 0.16.1 (#1203 proposed 0.16.0; 0.16.1 is the latest and adds only bug fixes and preview-rule changes on top of it) - types-setuptools 83.0.0.20260706 -> 83.0.0.20260724 (#1202) - types-python-dateutil 2.9.0.20260518 -> 2.9.0.20260716 (#1201) - types-tqdm 4.68.0.20260608 -> 4.70.0.20260805 (#1199) - neo4j-viz 1.6.0 -> 1.7.0 (#1200, lock only; the >=1.6.0 floor stays put so the constraint remains permissive for library consumers) - aiohttp 3.14.1 -> 3.14.3 (#1214) - cryptography 49.0.0 -> 50.0.0 (#1216) Also re-resolves the whole lockfile with `uv lock --upgrade` rather than only the packages dependabot filed PRs for, which moves 48 packages in total. The ones worth noting beyond the list above: pyarrow 24.0.0 -> 25.0.0, tqdm 4.68.4 -> 4.70.0 and multimethod 2.0.2 -> 2.1 are runtime dependencies; pandas goes 3.0.3 -> 3.0.5; twine 6.2.0 -> 7.0.0 affects the publish group only; and sphinx-autodoc-typehints 2.3.0 -> 3.0.1 plus alabaster 0.7.16 -> 1.0.0 are major bumps but transitive only, since neither is in the sphinx extension list and the theme is the vendored neo4j one. pyarrow 25 needs the mypy.ini change. It withdraws the py.typed marker and inline annotations that 24 shipped (apache/arrow#50168), because those annotations were incomplete and broke type checkers on submodules such as pyarrow.compute (apache/arrow#49831). Without py.typed, strict mypy reports 26 import-untyped errors across the arrow client. Restoring ignore_missing_imports for pyarrow reverts exactly what #1164 removed when it adopted pyarrow 24, so this is the pre-24 behaviour rather than a new relaxation. pyarrow-stubs is not a usable alternative: it targets the pyarrow 20 API and yields 35 errors in 7 files. The stanza can go once upstream ships complete annotations (apache/arrow#32609). Verified: ruff 0.16.1 reformats nothing and reports no new findings (the 0.16 default-rule expansion does not reach us because tool.ruff.lint.select is explicit, and the new markdown formatting is excluded by include), mypy is clean, and the 632 unit tests pass. The sphinx API docs still build with -W and the rendered HTML is byte-identical to a pre-upgrade build, so the sphinx transitive majors change no output. nbconvert still produces byte-identical asciidoc for the tutorial notebooks despite the mistune 3.3.2 -> 3.3.4 bump. The torch 2.12.1 -> 2.13.0 bump (#1186, #1192) is still left out, for the same reason as in #1196 and re-checked today: the PyG wheel index for torch-2.13.0+cpu ships only pyg_lib, no torch-scatter or torch-sparse wheels, so notebook-ci would fall back to building those from source. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Drop older pyarrow version --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Rationale for this change
Since 24.0, pyarrow ships annotations and
py.typedmarker while the type stubs are still incomplete. This makes type checkers trust the partial stubs and report false errors in downstream code (e.g. Module has no attribute "all" forpyarrow.compute). Some type checkers also consume bundled.pyifiles even withoutpy.typed, so the stubs need to be withheld from wheels for now. See #49831.What changes are included in this PR?
This temporarily omits both
pyarrow/py.typedand the bundledpyarrow-stubs/.pyifiles from built wheels until the stubs are complete. Wheel-content validation now asserts that neitherpy.typednor.pyifiles are present, and wheel build scripts no longer request stub docstring injection while stubs are not installed.Are these changes tested?
Wheel-content validation has been updated to check the intended absence of
py.typedand.pyifiles.Are there any user-facing changes?
Type checkers no longer pick up pyarrow's incomplete stubs from wheels.