Skip to content

Ship a PEP 561 py.typed marker - #1761

Open
rajeeja wants to merge 2 commits into
mainfrom
rajeeja/py-typed
Open

rajeeja wants to merge 2 commits into
mainfrom
rajeeja/py-typed

Conversation

@rajeeja

@rajeeja rajeeja commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Closes #1760

Overview

Adds the PEP 561 py.typed marker so type checkers are permitted to use the annotations uxarray already ships.

Without the marker, mypy and pyright treat every uxarray import as Any and discard all existing annotations, and --strict users get an error on import uxarray itself. Grid.n_face is declared -> int (uxarray/grid/grid.py:897) and that annotation does nothing for a user today — the mechanism that would consume it is simply absent. xarray, numpy and dask all ship the marker.

Two config changes are needed rather than one, because MANIFEST.in line 4 is recursive-include uxarray *.py: a non-.py file is silently dropped from the distribution even when it is present in git. [tool.setuptools.package-data] covers the wheel, MANIFEST.in covers the sdist.

Changes

  • uxarray/py.typed — new, empty
  • pyproject.toml[tool.setuptools.package-data]
  • MANIFEST.ininclude uxarray/py.typed
  • test/test_dependencies.py — assert the marker is present in the installed package

Verification

Built the wheel and sdist from this branch:

  • py.typed present in both
  • wheel contains 86 files vs 85 in the released 2026.9.0 — diff against that wheel shows exactly one file added, none removed
  • installed the wheel non-editable into a clean venv, confirmed the marker lands in site-packages
  • deleted the marker from that install and confirmed the new test fails, so it is not a tautology

The test asserts against the installed package rather than the source tree, since the source tree cannot catch a packaging regression.

Follow-up (not in this PR)

The marker is a promise, and coverage is currently thin: 213/798 functions have return annotations, and 227 public functions have none — including open_grid, open_dataset and open_mfdataset. So ux.open_grid("mesh.nc") still infers as Any and a downstream grid.n_face + "x" still goes uncaught. Annotating those constructors is the natural next step, and annotating open_grid first requires a decision about return_chunks, which is undocumented, untested, and used by exactly one private caller. Worth doing separately.

PR Checklist

General

  • An issue is created and linked
  • Added appropriate labels (if your uxarray repo permissions allow it)
  • Filled out Overview and Expected Usage (if applicable) sections

Testing

  • Tests added
  • [N/A] Benchmarks added

Documentation

  • [N/A] Docstrings on new functions
  • [N/A] Examples added

uxarray annotates its public API, but without a py.typed marker type
checkers discard every one of those annotations and --strict users get
an error on `import uxarray`. MANIFEST.in globs only *.py, so the
marker needs explicit package-data config to reach the wheel.

Verified by building the wheel and sdist: py.typed is present in both,
and the wheel gains exactly one file over the released 2026.9.0.
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.

Ship a PEP 561 py.typed marker

1 participant