From 04459647f4123e2fae9a9282bf52346b8246dd1e Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 29 Jul 2025 11:10:19 -0500 Subject: [PATCH 1/3] Add not_none --- pytools/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) 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() From f75a964742c21607486aad4f27226d92cc111afe Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 29 Jul 2025 11:14:38 -0500 Subject: [PATCH 2/3] Add ND __getitem__, __matmul__ to ObjectArray --- pytools/obj_array.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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]: ... From 616d629010b9f55779e87ae38ae30fb20a7a599f Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 29 Jul 2025 11:14:51 -0500 Subject: [PATCH 3/3] bpr: exclude irrelevant stuff --- pyproject.toml | 8 ++++++++ 1 file changed, 8 insertions(+) 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