From 023f4e5e8020d490d69faa6f7b0089d14191f110 Mon Sep 17 00:00:00 2001 From: w-bonelli Date: Thu, 23 Oct 2025 13:42:09 -0400 Subject: [PATCH] fixitagain --- xattree/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xattree/__init__.py b/xattree/__init__.py index 1cbd201..d9ca835 100644 --- a/xattree/__init__.py +++ b/xattree/__init__.py @@ -561,7 +561,11 @@ def _register_nested_dims(child_spec: Child, path=None): dtype = xatmeta.get(_DTYPE, None) # Extract dtype from type hint if not explicitly provided - if dtype is None and origin is np.ndarray and args: + if ( + dtype is None + and args + and (origin is np.ndarray or args[-1] is types.NoneType) + ): if len(args) >= 2 and hasattr(args[1], "__args__"): # Handle NDArray[np.float64] style hints dtype_arg = args[1].__args__[0] @@ -1233,7 +1237,8 @@ def array( raise CannotExpand("If no dims, no scalar defaults.") if dtype is not None and default is NOTHING: if isinstance(dtype, (str, np.dtype)): - default = _get_fill_value(np.dtype(dtype)) + dtype = np.dtype(dtype) + default = _get_fill_value(dtype) elif isinstance(dtype, type): default = Factory(dtype) else: