Skip to content

Commit c40333c

Browse files
committed
Revert BufferProtocol change
1 parent 25d9b5d commit c40333c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

arcade/types.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,11 @@ class TiledObject(NamedTuple):
501501
type: Optional[str] = None
502502

503503

504-
# This is a temporary workaround for the lack of a way to type annotate
505-
# objects implementing the buffer protocol. Although there is a PEP to
506-
# add typing, it is scheduled for 3.12. Since that is years away from
507-
# being our minimum Python version, we have to use a workaround. See
508-
# the PEP and Python doc for more information:
509-
# https://peps.python.org/pep-0688/
510-
# https://docs.python.org/3/c-api/buffer.html
511-
BufferProtocol = Union[ByteString, memoryview, array, ctypes.Array]
504+
if sys.version_info >= (3, 12):
505+
from collections.abc import Buffer as BufferProtocol
506+
else:
507+
# This is used instead of the typing_extensions version since they
508+
# use an ABC which registers virtual subclasses. This will not work
509+
# with ctypes.Array since virtual subclasses must be concrete.
510+
# See: https://peps.python.org/pep-0688/
511+
BufferProtocol = Union[ByteString, memoryview, array, ctypes.Array]

0 commit comments

Comments
 (0)