Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e50659

Browse files
authored
Merge pull request #28913 from charris/backport-28908
TYP: Fix non-existent ``CanIndex`` annotation in ``ndarray.setfield``
2 parents 7517cd1 + c906f84 commit 9e50659

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

numpy/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2551,7 +2551,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DType_co]):
25512551
@overload # (dtype: ?, type: type[T])
25522552
def view(self, /, dtype: DTypeLike, type: type[_ArrayT]) -> _ArrayT: ...
25532553

2554-
def setfield(self, /, val: ArrayLike, dtype: DTypeLike, offset: CanIndex = 0) -> None: ...
2554+
def setfield(self, /, val: ArrayLike, dtype: DTypeLike, offset: SupportsIndex = 0) -> None: ...
25552555
@overload
25562556
def getfield(self, dtype: _DTypeLike[_SCT], offset: SupportsIndex = 0) -> NDArray[_SCT]: ...
25572557
@overload

numpy/typing/tests/data/fail/array_like.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ scalar = np.int64(1)
1414
scalar.__array__(dtype=np.float64) # E: No overload variant
1515
array = np.array([1])
1616
array.__array__(dtype=np.float64) # E: No overload variant
17+
18+
array.setfield(np.eye(1), np.int32, (0, 1)) # E: No overload variant

0 commit comments

Comments
 (0)