@@ -25,13 +25,13 @@ def build_array(*args: tuple[Any], dtype: np.dtype, defaults: dict[str, np.gener
2525 return array
2626
2727 if isinstance (parsed_input , np .ndarray ) and parsed_input .dtype .names :
28- _check_missing_columns (array .dtype .names , defaults , set (parsed_input .dtype .names ))
28+ _check_missing_columns (array .dtype .names or () , defaults , set (parsed_input .dtype .names ))
2929 return _parse_structured_array (parsed_input , array )
3030 if isinstance (parsed_input , np .ndarray ):
3131 # Note: defaults are not supported when working with unstructured arrays
3232 return _parse_array (parsed_input , array .dtype )
3333
34- _check_missing_columns (array .dtype .names , defaults , set (parsed_input .keys ()))
34+ _check_missing_columns (array .dtype .names or () , defaults , set (parsed_input .keys ()))
3535 _fill_with_kwargs (array , parsed_input )
3636 return array
3737
@@ -54,7 +54,7 @@ def _parse_input(*args: Any, dtype: np.dtype, **kwargs):
5454 return {}, 0
5555
5656
57- def _check_missing_columns (array_columns : tuple , defaults : dict [str , np .generic ], provided_columns : set [str ]):
57+ def _check_missing_columns (array_columns : tuple [ str , ...] , defaults : dict [str , np .generic ], provided_columns : set [str ]):
5858 required_columns = set (array_columns ) - set (defaults .keys ())
5959 if missing_columns := required_columns - provided_columns :
6060 raise ValueError (f"Missing required columns: { missing_columns } " )
@@ -64,7 +64,8 @@ def _fill_defaults(array: np.ndarray, defaults: dict[str, np.generic]):
6464 """Fills the defaults into the array."""
6565 for column , default in defaults .items ():
6666 if default is empty :
67- array [column ] = empty (array .dtype [column ]) # type: ignore[call-overload]
67+ column_type : type = array .dtype [column ]
68+ array [column ] = empty (column_type ) # type: ignore[call-overload]
6869 else :
6970 array [column ] = default # type: ignore[call-overload]
7071
@@ -87,8 +88,8 @@ def _parse_structured_array(from_array: np.ndarray, to_array: np.ndarray) -> np.
8788
8889def _determine_column_overlap (from_array : np .ndarray , to_array : np .ndarray ) -> tuple [list [str ], list [str ]]:
8990 """Returns two lists: columns present in both arrays and the columns that are only present in from_array"""
90- from_columns = set (from_array .dtype .names )
91- to_columns = set (to_array .dtype .names )
91+ from_columns = set (from_array .dtype .names or () )
92+ to_columns = set (to_array .dtype .names or () )
9293
9394 return list (from_columns & to_columns ), list (from_columns - to_columns )
9495
0 commit comments