diff --git a/pyproject.toml b/pyproject.toml index 914ce17e..68d9854f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,6 +111,14 @@ reportUnusedCallResult = "none" reportExplicitAny = "none" reportUnreachable = "hint" +exclude = [ + "doc", + ".conda-root", + "build", + ".env", + ".run-pylint.py", +] + # This reports even cycles that are qualified by 'if TYPE_CHECKING'. Not what # we care about at this moment. # https://github.com/microsoft/pyright/issues/746 diff --git a/pytools/__init__.py b/pytools/__init__.py index 904b8662..433cbcad 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -3169,6 +3169,11 @@ def ndindex(shape: ShapeT) -> Iterable[ShapeT]: return np.ndindex(shape) +def not_none(obj: T | None) -> T: + assert obj is not None + return obj + + def _test(): import doctest doctest.testmod() diff --git a/pytools/obj_array.py b/pytools/obj_array.py index d50c1a4e..d6555144 100644 --- a/pytools/obj_array.py +++ b/pytools/obj_array.py @@ -173,6 +173,12 @@ def __getitem__(self: ObjectArray2D[T], x: int, /) -> ObjectArray1D[T]: ... @overload def __getitem__(self: ObjectArrayND[T], x: int, /) -> ObjectArrayND[T] | T: ... + @overload + def __getitem__( + self: ObjectArrayND[T], + x: tuple[int | slice, ...], + /) -> ObjectArrayND[T] | T: ... + @overload def __getitem__( self: ObjectArray1D[T], @@ -271,6 +277,12 @@ def __matmul__( other: ObjectArray2D[T], /) -> ObjectArray2D[T]: ... + @overload + def __matmul__( + self: ObjectArrayND[T], + other: ObjectArrayND[T], + /) -> ObjectArrayND[T] | T: ... + @property def flat(self) -> ObjectArray1D[T]: ...