Skip to content

Commit 19ee3d4

Browse files
committed
Use typing_extensions.Buffer in stubs
1 parent 41f11ed commit 19ee3d4

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

buildconfig/stubs/pygame/image.pyi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ from typing import Literal, Optional, Union
33
from pygame.bufferproxy import BufferProxy
44
from pygame.surface import Surface
55
from pygame.typing import FileLike, IntPoint, Point
6-
from typing_extensions import deprecated # added in 3.13
6+
from typing_extensions import (
7+
Buffer, # collections.abc 3.12
8+
deprecated, # added in 3.13
9+
)
710

8-
_BufferLike = Union[BufferProxy, bytes, bytearray, memoryview]
911
_from_buffer_format = Literal["P", "RGB", "BGR", "BGRA", "RGBX", "RGBA", "ARGB"]
1012
_to_bytes_format = Literal[
1113
"P", "RGB", "RGBX", "RGBA", "ARGB", "BGRA", "ABGR", "RGBA_PREMULT", "ARGB_PREMULT"
@@ -47,7 +49,7 @@ def frombytes(
4749
pitch: int = -1,
4850
) -> Surface: ...
4951
def frombuffer(
50-
buffer: _BufferLike,
52+
buffer: Buffer,
5153
size: IntPoint,
5254
format: _from_buffer_format,
5355
pitch: int = -1,

buildconfig/stubs/pygame/mixer.pyi

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from typing import Any, Optional, Union, overload
22

3-
import numpy
43
from pygame.event import Event
54
from pygame.typing import FileLike
6-
from typing_extensions import deprecated # added in 3.13
5+
from typing_extensions import (
6+
Buffer, # collections.abc 3.12
7+
deprecated, # added in 3.13
8+
)
79

810
from . import mixer_music
911

@@ -46,13 +48,7 @@ class Sound:
4648
@overload
4749
def __init__(self, file: FileLike) -> None: ...
4850
@overload
49-
def __init__(
50-
self, buffer: Any
51-
) -> None: ... # Buffer protocol is still not implemented in typing
52-
@overload
53-
def __init__(
54-
self, array: numpy.ndarray
55-
) -> None: ... # Buffer protocol is still not implemented in typing
51+
def __init__(self, buffer: Buffer) -> None: ...
5652
def play(
5753
self,
5854
loops: int = 0,

0 commit comments

Comments
 (0)