diff --git a/codegen/apipatcher.py b/codegen/apipatcher.py index f7303f7a..80371f20 100644 --- a/codegen/apipatcher.py +++ b/codegen/apipatcher.py @@ -624,6 +624,10 @@ def class_is_known(self, classname): def get_class_def(self, classname): line, _ = self.classes[classname] + if line.startswith("class GPUPromise"): + # otherwise the else block below strips the typevar. + return "class GPUPromise(classes.GPUPromise[AwaitedType]):" + if "):" not in line: return line.replace(":", f"(classes.{classname}):") else: diff --git a/wgpu/_classes.py b/wgpu/_classes.py index c1e6a502..d10edaeb 100644 --- a/wgpu/_classes.py +++ b/wgpu/_classes.py @@ -15,7 +15,7 @@ import itertools from typing import Sequence -from ._async import GPUPromise as BaseGPUPromise +from ._async import GPUPromise as BaseGPUPromise, AwaitedType from ._coreutils import ApiDiff, str_flag_to_int, ArrayLike, CanvasLike from ._diagnostics import diagnostics, texture_format_to_bpp from . import flags, enums, structs @@ -224,7 +224,7 @@ def get_canvas_context(self, present_info: dict) -> GPUCanvasContext: @apidiff.add("Added for async support") -class GPUPromise(BaseGPUPromise): +class GPUPromise(BaseGPUPromise[AwaitedType]): pass diff --git a/wgpu/backends/wgpu_native/_api.py b/wgpu/backends/wgpu_native/_api.py index c96ff973..ea99c39b 100644 --- a/wgpu/backends/wgpu_native/_api.py +++ b/wgpu/backends/wgpu_native/_api.py @@ -24,6 +24,7 @@ from typing import NoReturn, Sequence from ..._coreutils import str_flag_to_int, ArrayLike, CanvasLike +from ..._async import AwaitedType from ... import classes, flags, enums, structs from ._ffi import ffi, lib @@ -684,7 +685,7 @@ def get_canvas_context(self, present_info: dict) -> GPUCanvasContext: gpu = GPU() -class GPUPromise(classes.GPUPromise): +class GPUPromise(classes.GPUPromise[AwaitedType]): def _sync_wait(self): # In the wgpu-native backend, we do the polling in a per-device thread. # The base class already sets a threading.Event, we can just use that here.