22
22
from pandas ._libs .internals import BlockPlacement
23
23
from pandas ._typing import (
24
24
ArrayLike ,
25
- Dtype ,
26
25
DtypeObj ,
27
26
Shape ,
27
+ npt ,
28
28
type_t ,
29
29
)
30
30
from pandas .errors import PerformanceWarning
@@ -1389,7 +1389,7 @@ def to_dict(self, copy: bool = True):
1389
1389
def as_array (
1390
1390
self ,
1391
1391
transpose : bool = False ,
1392
- dtype : Dtype | None = None ,
1392
+ dtype : npt . DTypeLike | None = None ,
1393
1393
copy : bool = False ,
1394
1394
na_value = lib .no_default ,
1395
1395
) -> np .ndarray :
@@ -1429,17 +1429,21 @@ def as_array(
1429
1429
# error: Item "ndarray" of "Union[ndarray, ExtensionArray]" has no
1430
1430
# attribute "to_numpy"
1431
1431
arr = blk .values .to_numpy ( # type: ignore[union-attr]
1432
- dtype = dtype , na_value = na_value
1432
+ # pandas/core/internals/managers.py:1428: error: Argument "dtype" to
1433
+ # "to_numpy" of "ExtensionArray" has incompatible type
1434
+ # "Optional[Union[dtype[Any], None, type, _SupportsDType, str,
1435
+ # Union[Tuple[Any, int], Tuple[Any, Union[SupportsIndex,
1436
+ # Sequence[SupportsIndex]]], List[Any], _DTypeDict, Tuple[Any,
1437
+ # Any]]]]"; expected "Optional[Union[ExtensionDtype, Union[str,
1438
+ # dtype[Any]], Type[str], Type[float], Type[int], Type[complex],
1439
+ # Type[bool], Type[object]]]"
1440
+ dtype = dtype , # type: ignore[arg-type]
1441
+ na_value = na_value ,
1433
1442
).reshape (blk .shape )
1434
1443
else :
1435
1444
arr = np .asarray (blk .get_values ())
1436
1445
if dtype :
1437
- # error: Argument 1 to "astype" of "_ArrayOrScalarCommon" has
1438
- # incompatible type "Union[ExtensionDtype, str, dtype[Any],
1439
- # Type[object]]"; expected "Union[dtype[Any], None, type,
1440
- # _SupportsDType, str, Union[Tuple[Any, int], Tuple[Any, Union[int,
1441
- # Sequence[int]]], List[Any], _DTypeDict, Tuple[Any, Any]]]"
1442
- arr = arr .astype (dtype , copy = False ) # type: ignore[arg-type]
1446
+ arr = arr .astype (dtype , copy = False )
1443
1447
else :
1444
1448
arr = self ._interleave (dtype = dtype , na_value = na_value )
1445
1449
# The underlying data was copied within _interleave
@@ -1454,7 +1458,9 @@ def as_array(
1454
1458
return arr .transpose () if transpose else arr
1455
1459
1456
1460
def _interleave (
1457
- self , dtype : Dtype | None = None , na_value = lib .no_default
1461
+ self ,
1462
+ dtype : npt .DTypeLike | ExtensionDtype | None = None ,
1463
+ na_value = lib .no_default ,
1458
1464
) -> np .ndarray :
1459
1465
"""
1460
1466
Return ndarray from blocks with specified item order
@@ -1489,7 +1495,16 @@ def _interleave(
1489
1495
# error: Item "ndarray" of "Union[ndarray, ExtensionArray]" has no
1490
1496
# attribute "to_numpy"
1491
1497
arr = blk .values .to_numpy ( # type: ignore[union-attr]
1492
- dtype = dtype , na_value = na_value
1498
+ # pandas/core/internals/managers.py:1485: error: Argument "dtype" to
1499
+ # "to_numpy" of "ExtensionArray" has incompatible type
1500
+ # "Union[dtype[Any], None, type, _SupportsDType, str, Tuple[Any,
1501
+ # Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any],
1502
+ # _DTypeDict, Tuple[Any, Any], ExtensionDtype]"; expected
1503
+ # "Optional[Union[ExtensionDtype, Union[str, dtype[Any]], Type[str],
1504
+ # Type[float], Type[int], Type[complex], Type[bool], Type[object]]]"
1505
+ # [arg-type]
1506
+ dtype = dtype , # type: ignore[arg-type]
1507
+ na_value = na_value ,
1493
1508
)
1494
1509
else :
1495
1510
# error: Argument 1 to "get_values" of "Block" has incompatible type
0 commit comments