diff --git a/ruff.toml b/ruff.toml index 6e7edfc4bb..7f860b8b3a 100644 --- a/ruff.toml +++ b/ruff.toml @@ -12,8 +12,8 @@ lint.select = [ # "E124", "E203", # whitespace-before-punctuation "E272", # multiple-spaces-before-keyword - "E303", - "E304", + "E303", # too-many-blank-lines + "E304", # blank-line-after-decorator "E501", # line-too-long # "E502", "E702", # multiple-statements-on-one-line-semicolon @@ -24,6 +24,8 @@ lint.select = [ "W293", # blank-line-with-whitespace "UP039", # unnecessary-class-parentheses "C416", # unnecessary-comprehension + "RET506", # superfluous-else-raise + "RET507", # superfluous-else-continue ] line-length = 150 diff --git a/tinygrad/runtime/ops_amd.py b/tinygrad/runtime/ops_amd.py index 32ba7a69a1..3eb715d696 100644 --- a/tinygrad/runtime/ops_amd.py +++ b/tinygrad/runtime/ops_amd.py @@ -395,7 +395,7 @@ class AMDAllocator(HCQCompatAllocator): return self.device._gpu_alloc(size, kfd.KFD_IOC_ALLOC_MEM_FLAGS_VRAM, public=options.cpu_access) except OSError as e: if e.errno == errno.ENOMEM: raise MemoryError("Cannot allocate memory") from e - else: raise + raise def _free(self, opaque, options:BufferOptions): self.device._gpu_free(opaque) diff --git a/tinygrad/runtime/ops_python.py b/tinygrad/runtime/ops_python.py index 4c032c04cb..7f9fbc1d0d 100644 --- a/tinygrad/runtime/ops_python.py +++ b/tinygrad/runtime/ops_python.py @@ -63,11 +63,11 @@ class PythonProgram: if g: _store(m, o, v) i += 1 continue - elif uop is UOps.ENDRANGE: + if uop is UOps.ENDRANGE: loop_ends[idp[0]] = i i = idp[0] continue - elif uop in (UOps.BARRIER, UOps.IF, UOps.ENDIF): + if uop in (UOps.BARRIER, UOps.IF, UOps.ENDIF): # in the python emulator, the warp is always in sync i += 1 continue diff --git a/tinygrad/tensor.py b/tinygrad/tensor.py index b2c643d027..772cf14fe3 100644 --- a/tinygrad/tensor.py +++ b/tinygrad/tensor.py @@ -770,7 +770,7 @@ class Tensor: new_shape = tuple([s if s is not None else self.shape[i] for i,s in enumerate(argfix(shape, *args))]) # resolve -1 if (c := new_shape.count(-1)) > 1: raise RuntimeError(f"only one dimension can be inferred using -1, getting {new_shape}") - elif c: new_shape = tuple([-prod(self.shape) // prod(new_shape) if s == -1 else s for s in new_shape]) + if c: new_shape = tuple([-prod(self.shape) // prod(new_shape) if s == -1 else s for s in new_shape]) return F.Reshape.apply(self, shape=new_shape) if new_shape != self.shape else self def expand(self, shape, *args) -> Tensor: