Skip to content

Commit f99a87a

Browse files
committed
Constrain memoryview type var to allowed types
1 parent e18b99c commit f99a87a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stdlib/builtins.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ if sys.version_info >= (3, 9):
7676
from types import GenericAlias
7777

7878
_T = TypeVar("_T")
79-
_I = TypeVar("_I", default=int)
79+
_I = TypeVar("_I", int, bytes, float, bool, default=int) # possibly memoryview types
8080
_T_co = TypeVar("_T_co", covariant=True)
8181
_T_contra = TypeVar("_T_contra", contravariant=True)
8282
_R_co = TypeVar("_R_co", covariant=True)
@@ -882,7 +882,7 @@ class memoryview(Sequence[_I]):
882882
@overload
883883
def cast(self, format: Literal["?"], shape: list[int] | tuple[int, ...] = ...) -> memoryview[bool]: ...
884884
@overload
885-
def cast(self, format: _IntegerFormats, shape: list[int] | tuple[int, ...] = ...) -> memoryview: ...
885+
def cast(self, format: _IntegerFormats, shape: list[int] | tuple[int, ...] = ...) -> memoryview[int]: ...
886886
@overload
887887
def __getitem__(self, key: SupportsIndex | tuple[SupportsIndex, ...], /) -> _I: ...
888888
@overload

0 commit comments

Comments
 (0)