Skip to content

Commit 6de1fac

Browse files
committed
♻️ remove the custom __buffer__ protocol
1 parent e376daa commit 6de1fac

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/numpy-stubs/_typing/_array_like.pyi

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import sys
21
from collections.abc import Callable, Collection, Sequence
32
from typing import Any, Protocol, TypeAlias, runtime_checkable
4-
from typing_extensions import TypeVar
3+
from typing_extensions import Buffer, TypeVar
54

65
import numpy as np
76
from numpy.dtypes import StringDType
@@ -10,12 +9,6 @@ from ._nbit_base import _64Bit
109
from ._nested_sequence import _NestedSequence
1110
from ._shape import _Shape
1211

13-
if sys.version_info >= (3, 12):
14-
from collections.abc import Buffer as _Buffer
15-
else:
16-
class _Buffer(Protocol):
17-
def __buffer__(self, flags: int, /) -> memoryview: ...
18-
1912
_T = TypeVar("_T")
2013
_ScalarType = TypeVar("_ScalarType", bound=np.generic)
2114
_ScalarType_co = TypeVar("_ScalarType_co", bound=np.generic, covariant=True)
@@ -55,7 +48,7 @@ _ArrayLike: TypeAlias = _SupportsArray[np.dtype[_ScalarType]] | _NestedSequence[
5548
# and another one for the rest
5649
_DualArrayLike: TypeAlias = _SupportsArray[_DType] | _T | _NestedSequence[_T] | _NestedSequence[_SupportsArray[_DType]]
5750

58-
ArrayLike: TypeAlias = _Buffer | _DualArrayLike[np.dtype[Any], complex | str | bytes]
51+
ArrayLike: TypeAlias = _DualArrayLike[np.dtype[Any], complex | str | bytes] | Buffer
5952

6053
# `ArrayLike<X>_co`: array-like objects that can be coerced into `X`
6154
# given the casting rules `same_kind`

0 commit comments

Comments
 (0)