Fix jaxtyping>=0.3.0 support for NumPy annotations#730
Merged
yukinarit merged 1 commit intoyukinarit:mainfrom Mar 18, 2026
Merged
Fix jaxtyping>=0.3.0 support for NumPy annotations#730yukinarit merged 1 commit intoyukinarit:mainfrom
yukinarit merged 1 commit intoyukinarit:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #730 +/- ##
==========================================
- Coverage 90.83% 90.81% -0.03%
==========================================
Files 13 13
Lines 2040 2307 +267
Branches 370 449 +79
==========================================
+ Hits 1853 2095 +242
- Misses 124 141 +17
- Partials 63 71 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #643.
Summary
I used Codex to help investigate the regression, isolate the root cause, and validate the fix.
pyserde's jaxtyping support broke withjaxtyping>=0.3.0because jaxtyping annotations no longer subclass their backing array type.Before
0.3.0, an annotation likejaxtyping.Float[np.ndarray, "2 2"]was a subclass ofnp.ndarray, so pyserde detected it withissubclass(..., np.ndarray).From
0.3.0onward, jaxtyping annotations inherit fromjaxtyping.AbstractArrayinstead, while still exposingarray_type. That caused pyserde's jaxtyping NumPy handling to stop matching and fall through toSerdeError: Unsupported type: ndarray.This patch keeps the fix small:
jaxtyping.AbstractArrayplusarray_type is np.ndarrayjaxtyping<0.3.0pinLocal validation
Ran locally:
make test make examples uv run pytest tests/test_numpy.py -k jaxtyping -v uv run python examples/type_numpy_jaxtyping.py uv run ruff check serde/numpy.py tests/test_numpy.py examples/type_numpy_jaxtyping.py