From 05294bc648bd35acb05f95ddafa604705bf05c31 Mon Sep 17 00:00:00 2001 From: chenyu Date: Tue, 18 Nov 2025 09:23:42 -0500 Subject: [PATCH] fix some mypy cast [pr] (#13331) --- tinygrad/uop/ops.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tinygrad/uop/ops.py b/tinygrad/uop/ops.py index 8c86029e81..2f5877e772 100644 --- a/tinygrad/uop/ops.py +++ b/tinygrad/uop/ops.py @@ -89,8 +89,8 @@ class UOpMetaClass(type): if SPEC > 1: from tinygrad.uop.spec import full_spec, test_pyrender if SPEC > 2: test_pyrender(created) - with Context(IGNORE_OOB=1): ret = full_spec.rewrite(created) - if cast(bool|None, ret) is not True: raise RuntimeError(f"SPEC ISSUE {ret}: {created}") + with Context(IGNORE_OOB=1): fret = cast(bool|None, full_spec.rewrite(created)) + if fret is not True: raise RuntimeError(f"SPEC ISSUE {fret}: {created}") return created # some uops map to other stuff @@ -583,7 +583,7 @@ class UOp(OpMixin, metaclass=UOpMetaClass): def new_buffer(device:str|tuple[str, ...], size:int, dtype:DType, num=None): return UOp(Ops.BUFFER, dtype, (UOp.unique(num), UOp(Ops.DEVICE, arg=device)), size) @property - def device(self) -> str|tuple[str, ...]: return cast(str|tuple[str, ...], unwrap(self._device)) + def device(self) -> str|tuple[str, ...]: return unwrap(self._device) @recursive_property def _device(self) -> str|tuple[str, ...]|None: if self.op is Ops.DEVICE: return self.arg @@ -1164,12 +1164,12 @@ class RewriteContext: def cached_pm_rewrite(self, x:UOp): if (ret:=self.pm_cache.get(x,SENTINEL)) is not SENTINEL: return ret - ret = self.pm_cache[x] = cast(PatternMatcher, self.pm).rewrite(x, self.ctx) + ret = self.pm_cache[x] = unwrap(self.pm).rewrite(x, self.ctx) return ret def cached_bpm_rewrite(self, x:UOp): if (ret:=self.bpm_cache.get(x,SENTINEL)) is not SENTINEL: return ret - ret = self.bpm_cache[x] = cast(PatternMatcher, self.bpm).rewrite(x, self.ctx) + ret = self.bpm_cache[x] = unwrap(self.bpm).rewrite(x, self.ctx) return ret def unified_rewrite(self, root:UOp) -> UOp: