File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 55
66from __future__ import annotations
77
8+ import sys
89from array import array
910import ctypes
1011import random
@@ -449,11 +450,11 @@ class TiledObject(NamedTuple):
449450 type : Optional [str ] = None
450451
451452
452- # This is a temporary workaround for the lack of a way to type annotate
453- # objects implementing the buffer protocol. Although there is a PEP to
454- # add typing, it is scheduled for 3.12. Since that is years away from
455- # being our minimum Python version, we have to use a workaround. See
456- # the PEP and Python doc for more information:
457- # https://peps.python.org/pep-0688/
458- # https://docs .python.org/3/c-api/buffer.html
459- BufferProtocol = Union [ByteString , memoryview , array , ctypes .Array ]
453+ if sys . version_info >= ( 3 , 12 ):
454+ from collections . abc import Buffer as BufferProtocol
455+ else :
456+ # This is used instead of the typing_extensions version since they
457+ # use an ABC which registers virtual subclasses. This will not work
458+ # with ctypes.Array since virtual subclasses must be concrete.
459+ # See: https://peps .python.org/pep-0688/
460+ BufferProtocol = Union [ByteString , memoryview , array , ctypes .Array ]
You can’t perform that action at this time.
0 commit comments