Skip to content

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

Open
rok wants to merge 1 commit 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 1 commit 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). See #49831.

What changes are included in this PR?

This excludes pyarrow/py.typed from the built wheel via wheel.exclude.

Are these changes tested?

Verified on locally installed wheel with py.typed absent mypy ignores the bundled stubs.

Are there any user-facing changes?

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

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.
# https://github.com/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 😔

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