From 086bd035e7a73f9e6f28790683bf4c3ffaf04497 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 7 Jul 2023 17:13:42 +0800 Subject: [PATCH] sync pyglet update (typing --- libs/pyglet/__init__.py | 2 ++ libs/pyglet/types.py | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 libs/pyglet/types.py diff --git a/libs/pyglet/__init__.py b/libs/pyglet/__init__.py index 7f743b1..82e8730 100644 --- a/libs/pyglet/__init__.py +++ b/libs/pyglet/__init__.py @@ -333,6 +333,7 @@ class _ModuleProxy: # Lazily load all modules, except if performing # type checking or code inspection. if TYPE_CHECKING: + from . import types from . import app from . import canvas from . import clock @@ -353,6 +354,7 @@ if TYPE_CHECKING: from . import text from . import window else: + types = _ModuleProxy('types') app = _ModuleProxy('app') canvas = _ModuleProxy('canvas') clock = _ModuleProxy('clock') diff --git a/libs/pyglet/types.py b/libs/pyglet/types.py new file mode 100644 index 0000000..6b583e7 --- /dev/null +++ b/libs/pyglet/types.py @@ -0,0 +1,10 @@ +"""Holds type aliases used throughout the codebase.""" +import ctypes +from typing import Union + +__all__ = [ + "Buffer" +] + +# Backwards compatible placeholder for `collections.abc.Buffer` from Python 3.12 +Buffer = Union[bytes, bytearray, memoryview, ctypes.Array]