@@ -901,6 +901,7 @@ _ArrayLikeInt: TypeAlias = (
901
901
)
902
902
903
903
_FlatIterSelf = TypeVar ("_FlatIterSelf" , bound = flatiter [Any ])
904
+ _FlatShapeType = TypeVar ("_FlatShapeType" , bound = tuple [int ])
904
905
905
906
@final
906
907
class flatiter (Generic [_NdArraySubClass ]):
@@ -935,6 +936,10 @@ class flatiter(Generic[_NdArraySubClass]):
935
936
value : Any ,
936
937
) -> None : ...
937
938
@overload
939
+ def __array__ (self : flatiter [ndarray [_FlatShapeType , _DType ]], dtype : None = ..., / ) -> ndarray [_FlatShapeType , _DType ]: ...
940
+ @overload
941
+ def __array__ (self : flatiter [ndarray [_FlatShapeType , Any ]], dtype : _DType , / ) -> ndarray [_FlatShapeType , _DType ]: ...
942
+ @overload
938
943
def __array__ (self : flatiter [ndarray [Any , _DType ]], dtype : None = ..., / ) -> ndarray [Any , _DType ]: ...
939
944
@overload
940
945
def __array__ (self , dtype : _DType , / ) -> ndarray [Any , _DType ]: ...
@@ -1469,11 +1474,11 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
1469
1474
@overload
1470
1475
def __array__ (
1471
1476
self , dtype : None = ..., / , * , copy : None | bool = ...
1472
- ) -> ndarray [Any , _DType_co ]: ...
1477
+ ) -> ndarray [_ShapeType , _DType_co ]: ...
1473
1478
@overload
1474
1479
def __array__ (
1475
1480
self , dtype : _DType , / , * , copy : None | bool = ...
1476
- ) -> ndarray [Any , _DType ]: ...
1481
+ ) -> ndarray [_ShapeType , _DType ]: ...
1477
1482
1478
1483
def __array_ufunc__ (
1479
1484
self ,
@@ -1704,11 +1709,13 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType, _DType_co]):
1704
1709
axis : None | SupportsIndex = ...,
1705
1710
) -> ndarray [Any , _DType_co ]: ...
1706
1711
1712
+ # TODO: use `tuple[int]` as shape type once covariant (#26081)
1707
1713
def flatten (
1708
1714
self ,
1709
1715
order : _OrderKACF = ...,
1710
1716
) -> ndarray [Any , _DType_co ]: ...
1711
1717
1718
+ # TODO: use `tuple[int]` as shape type once covariant (#26081)
1712
1719
def ravel (
1713
1720
self ,
1714
1721
order : _OrderKACF = ...,
@@ -2613,6 +2620,7 @@ _NBit2 = TypeVar("_NBit2", bound=NBitBase)
2613
2620
class generic (_ArrayOrScalarCommon ):
2614
2621
@abstractmethod
2615
2622
def __init__ (self , * args : Any , ** kwargs : Any ) -> None : ...
2623
+ # TODO: use `tuple[()]` as shape type once covariant (#26081)
2616
2624
@overload
2617
2625
def __array__ (self : _ScalarType , dtype : None = ..., / ) -> NDArray [_ScalarType ]: ...
2618
2626
@overload
@@ -3740,6 +3748,7 @@ class poly1d:
3740
3748
3741
3749
__hash__ : ClassVar [None ] # type: ignore
3742
3750
3751
+ # TODO: use `tuple[int]` as shape type once covariant (#26081)
3743
3752
@overload
3744
3753
def __array__ (self , t : None = ..., copy : None | bool = ...) -> NDArray [Any ]: ...
3745
3754
@overload
0 commit comments