Skip to content

Add a py.typed marker and fix type errors against a typed fetchez - #200

Merged
matth-love merged 2 commits into
mainfrom
add-py-typed
Oct 21, 2026
Merged

matth-love merged 2 commits into
mainfrom
add-py-typed

Conversation

@mmacferrin

@mmacferrin mmacferrin commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds an empty src/transformez/py.typed file. Under PEP 561, type checkers such as mypy only read an installed package's annotations when it carries this marker. Without it, they treat everything imported from transformez as Any, and downstream projects have to list transformez under ignore_missing_imports in their mypy settings. With it, calls into transformez are checked against its annotations in the calling project's type check.

This came out of a review of IVERT's CI (continuous-dems/ivert#220), which suggested marking fetchez, transformez and globato as typed, but only where the package itself is type-checked. transformez is: the "Type check" workflow runs mypy on every pull request.

The wheel and sdist pick up the file without any configuration change, since hatch includes everything under src/transformez; I checked that a built wheel contains it. IVERT, which imports transformez, has no new type errors with the marker in place.

fetchez is getting the same marker in continuous-dems/fetchez#501. Once that is released, this repository's "Type check" workflow, which installs the newest fetchez, will check how transformez calls it. Against that branch it found 16 errors. Half come from fetchez annotations that #501 tightens; this PR fixes the other 8, none of which change behavior:

  • reference/fetcher.py gives the downloaded file names their own loop variable, rather than reassigning the loop's str variable to a Path (7 errors).
  • api.plot_grid() is annotated to take a region string or list as well as a Region, as its docstring and code already do; transformez build --preview passes it a string (1 error).

With both PRs in, the type check is clean. This PR should be merged before the fetchez release that carries #501, or the "Type check" workflow will fail on every PR here until it is.


Checklist

  • PR title is descriptive
  • PR body contains links to related and resolved issues (e.g. closes #1)
  • If needed, CHANGELOG.md updated
  • If needed, docs and/or README.md updated n/a
  • If needed, unit tests added n/a
  • All checks passing
  • At least one approval

🔍 Docs preview: https://transformez--200.org.readthedocs.build/en/200/

Type checkers only read a package's annotations when it carries this marker (PEP 561), so code that uses transformez can now be checked against them.
Gives the downloaded file names their own loop variable in the reference fetcher, rather than reusing it for the Path, and lets plot_grid() take a region string or list, as its docstring and code already do.
@matth-love
matth-love merged commit 32ff171 into main Oct 21, 2026
6 checks passed
@matth-love
matth-love deleted the add-py-typed branch October 21, 2026 15:17
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