Skip to content

Fix Python float/int validation against float64/int64 specs#1410

Merged
rly merged 3 commits intodevfrom
fix-python-float-int-validation
Mar 2, 2026
Merged

Fix Python float/int validation against float64/int64 specs#1410
rly merged 3 commits intodevfrom
fix-python-float-int-validation

Conversation

@rly
Copy link
Contributor

@rly rly commented Feb 26, 2026

Summary

  • Python native float is 64-bit, but get_type() was returning "float" which aliases to float32 in the spec system, causing validation failures against float64 specs
  • Same issue for Python native int (64-bit or larger) returning "int" which aliases to int32
  • Fixed get_type() to return "float64" for Python float and "int64" for Python int
  • Uses exact type check (type(data) is float) to avoid catching numpy subclasses or bool
  • Backward compatible: specs expecting float32/int32 already accept float64/int64 via additional_allowed

Fixes #1368

Test plan

  • Added test: Python float validates against float64 spec (was failing, now passes)
  • Added test: Python int validates against int64 spec (was failing, now passes)
  • Added test: Python float still validates against float (float32) spec (regression check)
  • Added test: Python int still validates against int (int32) spec (regression check)
  • All 91 validator tests pass

🤖 Generated with Claude Code

rly and others added 2 commits February 26, 2026 15:47
…pecs

Python native `float` and `int` are 64-bit, but `get_type()` was returning
"float" and "int" which map to float32 and int32 in the spec system. This
caused validation failures when Zarr attributes (read from JSON as native
Python types) were checked against float64/int64 specs. Now `get_type()`
returns "float64" for Python `float` and "int64" for Python `int`.

Fixes #1368

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rly rly requested a review from oruebel February 27, 2026 00:33
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.85%. Comparing base (b1f381a) to head (7d2bd71).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1410   +/-   ##
=======================================
  Coverage   92.84%   92.85%           
=======================================
  Files          41       41           
  Lines        9986     9990    +4     
  Branches     2052     2054    +2     
=======================================
+ Hits         9272     9276    +4     
  Misses        436      436           
  Partials      278      278           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rly rly enabled auto-merge (squash) March 2, 2026 18:25
@rly rly merged commit 814ae78 into dev Mar 2, 2026
28 checks passed
@rly rly deleted the fix-python-float-int-validation branch March 2, 2026 19:19
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.

[Bug]: Python float attributes not valid against float64 spec

2 participants