@@ -2189,10 +2189,7 @@ def raise_construction_error(
2189
2189
# -----------------------------------------------------------------------
2190
2190
2191
2191
2192
- def _grouping_func (tup : tuple [int , ArrayLike ]) -> tuple [int , bool , DtypeObj ]:
2193
- # compat for numpy<1.21, in which comparing a np.dtype with an ExtensionDtype
2194
- # raises instead of returning False. Once earlier numpy versions are dropped,
2195
- # this can be simplified to `return tup[1].dtype`
2192
+ def _grouping_func (tup : tuple [int , ArrayLike ]) -> tuple [int , DtypeObj ]:
2196
2193
dtype = tup [1 ].dtype
2197
2194
2198
2195
if is_1d_only_ea_dtype (dtype ):
@@ -2202,15 +2199,14 @@ def _grouping_func(tup: tuple[int, ArrayLike]) -> tuple[int, bool, DtypeObj]:
2202
2199
else :
2203
2200
sep = 0
2204
2201
2205
- return sep , isinstance ( dtype , np . dtype ), dtype
2202
+ return sep , dtype
2206
2203
2207
2204
2208
2205
def _form_blocks (arrays : list [ArrayLike ], consolidate : bool , refs : list ) -> list [Block ]:
2209
2206
tuples = list (enumerate (arrays ))
2210
2207
2211
2208
if not consolidate :
2212
- nbs = _tuples_to_blocks_no_consolidate (tuples , refs )
2213
- return nbs
2209
+ return _tuples_to_blocks_no_consolidate (tuples , refs )
2214
2210
2215
2211
# when consolidating, we can ignore refs (either stacking always copies,
2216
2212
# or the EA is already copied in the calling dict_to_mgr)
@@ -2219,8 +2215,8 @@ def _form_blocks(arrays: list[ArrayLike], consolidate: bool, refs: list) -> list
2219
2215
# group by dtype
2220
2216
grouper = itertools .groupby (tuples , _grouping_func )
2221
2217
2222
- nbs = []
2223
- for (_ , _ , dtype ), tup_block in grouper :
2218
+ nbs : list [ Block ] = []
2219
+ for (_ , dtype ), tup_block in grouper :
2224
2220
block_type = get_block_type (dtype )
2225
2221
2226
2222
if isinstance (dtype , np .dtype ):
0 commit comments