From 4c7e0f3de35926d58b13f2e95761ecf8b74c5e99 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 31 Aug 2025 14:23:37 -0500 Subject: [PATCH 1/2] Fixes for new typing failures --- arraycontext/impl/pytato/__init__.py | 2 +- arraycontext/pytest.py | 13 ++++++++++--- doc/conf.py | 9 +++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/arraycontext/impl/pytato/__init__.py b/arraycontext/impl/pytato/__init__.py index f76ab825..58d18b7b 100644 --- a/arraycontext/impl/pytato/__init__.py +++ b/arraycontext/impl/pytato/__init__.py @@ -653,7 +653,7 @@ def _to_frozen( transformed_dag = self.transform_dag(normalized_expr) from pytato.tags import PrefixNamed - name_hint_tags = [] + name_hint_tags: list[PrefixNamed] = [] for subary in key_to_pt_arrays.values(): name_hint_tags.extend(subary.tags_of_type(PrefixNamed)) diff --git a/arraycontext/pytest.py b/arraycontext/pytest.py index 75e19bc6..45319ea5 100644 --- a/arraycontext/pytest.py +++ b/arraycontext/pytest.py @@ -33,7 +33,7 @@ THE SOFTWARE. """ -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any, cast from typing_extensions import override @@ -43,6 +43,8 @@ if TYPE_CHECKING: from collections.abc import Callable, Sequence + import pyopencl as cl + from arraycontext.context import ArrayContext @@ -62,14 +64,16 @@ class PytestPyOpenCLArrayContextFactory(PytestArrayContextFactory): .. automethod:: __init__ .. automethod:: __call__ """ + device: cl.Device - def __init__(self, device): + def __init__(self, device: cl.Device): """ :arg device: a :class:`pyopencl.Device`. """ self.device = device @classmethod + @override def is_available(cls) -> bool: try: import pyopencl # noqa: F401 @@ -384,7 +388,10 @@ def inner(metafunc): if pyopencl_factories: for arg_dict in arg_values: arg_values_with_actx.extend([ - {factory_arg_name: factory(arg_dict["device"]), **arg_dict} + {factory_arg_name: cast( + "type[PytestPyOpenCLArrayContextFactory]", + factory)(cast("cl.Device", arg_dict["device"])), + **arg_dict} for factory in pyopencl_factories ]) diff --git a/doc/conf.py b/doc/conf.py index f2acda4f..fe998eed 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -46,3 +46,12 @@ ["py:class", r"np.integer"], ["py:class", r".*\|.*"], ] + +sphinxconfig_missing_reference_aliases = { + # pyopencl + "cl.Device": "obj:pyopencl.Device", +} + + +def setup(app): + app.connect("missing-reference", process_autodoc_missing_reference) # noqa: F821 From d8d9ca32ff52a952d97346bb520f534fecd5cd6d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sun, 31 Aug 2025 14:23:41 -0500 Subject: [PATCH 2/2] Update baseline --- .basedpyright/baseline.json | 1000 +++-------------------------------- 1 file changed, 75 insertions(+), 925 deletions(-) diff --git a/.basedpyright/baseline.json b/.basedpyright/baseline.json index 46683bfa..594d6078 100644 --- a/.basedpyright/baseline.json +++ b/.basedpyright/baseline.json @@ -35,508 +35,18 @@ } ], "./arraycontext/container/__init__.py": [ - { - "code": "reportUnusedParameter", - "range": { - "startColumn": 8, - "endColumn": 18, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 43, - "endColumn": 55, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 31, - "endColumn": 43, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 31, - "endColumn": 43, - "lineCount": 1 - } - }, - { - "code": "reportCallIssue", - "range": { - "startColumn": 8, - "endColumn": 17, - "lineCount": 1 - } - }, - { - "code": "reportArgumentType", - "range": { - "startColumn": 8, - "endColumn": 17, - "lineCount": 1 - } - }, - { - "code": "reportArgumentType", - "range": { - "startColumn": 23, - "endColumn": 39, - "lineCount": 1 - } - }, - { - "code": "reportUnusedParameter", - "range": { - "startColumn": 45, - "endColumn": 47, - "lineCount": 1 - } - } - ], - "./arraycontext/container/arithmetic.py": [ - { - "code": "reportUnusedParameter", - "range": { - "startColumn": 23, - "endColumn": 27, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 22, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 8, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 8, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 8, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 8, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 8, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 8, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 8, - "endColumn": 12, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 13, - "endColumn": 16, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 23, - "endColumn": 26, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 58, - "endColumn": 61, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 26, - "endColumn": 38, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 27, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 31, - "endColumn": 34, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 38, - "endColumn": 50, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 36, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 42, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 12, - "endColumn": 21, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 57, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 59, - "endColumn": 68, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 32, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 34, - "endColumn": 43, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 20, - "endColumn": 51, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 20, - "endColumn": 65, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 36, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 42, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 12, - "endColumn": 25, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 28, - "endColumn": 61, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 29, - "endColumn": 37, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 39, - "endColumn": 47, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 50, - "endColumn": 59, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 61, - "endColumn": 70, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 25, - "endColumn": 33, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 35, - "endColumn": 44, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 48, - "endColumn": 56, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 58, - "endColumn": 67, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 55, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 69, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 71, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 55, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 69, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 71, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 12, - "endColumn": 41, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 44, - "endColumn": 77, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 60, - "endColumn": 69, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 24, - "endColumn": 32, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 34, - "endColumn": 43, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 20, - "endColumn": 51, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 20, - "endColumn": 65, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 12, - "endColumn": 41, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 44, - "endColumn": 77, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 68, - "endColumn": 77, - "lineCount": 1 - } - }, { "code": "reportAny", "range": { - "startColumn": 24, - "endColumn": 32, + "startColumn": 43, + "endColumn": 55, "lineCount": 1 } }, { "code": "reportAny", "range": { - "startColumn": 34, + "startColumn": 31, "endColumn": 43, "lineCount": 1 } @@ -544,51 +54,45 @@ { "code": "reportAny", "range": { - "startColumn": 20, - "endColumn": 51, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 20, - "endColumn": 65, + "startColumn": 31, + "endColumn": 43, "lineCount": 1 } }, { - "code": "reportAny", + "code": "reportCallIssue", "range": { - "startColumn": 28, - "endColumn": 40, + "startColumn": 8, + "endColumn": 17, "lineCount": 1 } }, { - "code": "reportAny", + "code": "reportArgumentType", "range": { - "startColumn": 28, - "endColumn": 46, + "startColumn": 8, + "endColumn": 17, "lineCount": 1 } }, { - "code": "reportAny", + "code": "reportArgumentType", "range": { - "startColumn": 56, - "endColumn": 68, + "startColumn": 23, + "endColumn": 39, "lineCount": 1 } }, { - "code": "reportAny", + "code": "reportUnusedParameter", "range": { - "startColumn": 15, - "endColumn": 18, + "startColumn": 45, + "endColumn": 47, "lineCount": 1 } - }, + } + ], + "./arraycontext/container/arithmetic.py": [ { "code": "reportAny", "range": { @@ -783,38 +287,6 @@ } ], "./arraycontext/container/dataclass.py": [ - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 24, - "endColumn": 33, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 48, - "endColumn": 60, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 62, - "endColumn": 78, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 12, - "endColumn": 22, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -5065,22 +4537,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 19, - "endColumn": 39, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 19, - "endColumn": 52, - "lineCount": 2 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -6317,46 +5773,6 @@ "lineCount": 3 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 20, - "endColumn": 41, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 36, - "endColumn": 49, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 16, - "endColumn": 25, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 43, - "endColumn": 52, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 57, - "endColumn": 59, - "lineCount": 1 - } - }, { "code": "reportUnknownVariableType", "range": { @@ -9828,207 +9244,95 @@ } }, { - "code": "reportAny", - "range": { - "startColumn": 23, - "endColumn": 33, - "lineCount": 3 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 64, - "endColumn": 68, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 70, - "endColumn": 74, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 38, - "endColumn": 42, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 55, - "endColumn": 68, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 55, - "endColumn": 68, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 45, - "endColumn": 48, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 62, - "endColumn": 66, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 52, - "endColumn": 56, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 58, - "endColumn": 62, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 53, - "endColumn": 82, - "lineCount": 1 - } - } - ], - "./arraycontext/pytest.py": [ - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 23, - "endColumn": 29, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 23, - "endColumn": 29, - "lineCount": 1 - } - }, - { - "code": "reportUnannotatedClassAttribute", - "range": { - "startColumn": 13, - "endColumn": 19, - "lineCount": 1 - } - }, - { - "code": "reportImplicitOverride", - "range": { - "startColumn": 8, - "endColumn": 20, - "lineCount": 1 + "code": "reportAny", + "range": { + "startColumn": 23, + "endColumn": 33, + "lineCount": 3 } }, { - "code": "reportUnusedImport", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 19, - "endColumn": 27, + "startColumn": 64, + "endColumn": 68, "lineCount": 1 } }, { - "code": "reportUnannotatedClassAttribute", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 4, - "endColumn": 25, + "startColumn": 70, + "endColumn": 74, "lineCount": 1 } }, { - "code": "reportImplicitOverride", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 8, - "endColumn": 16, + "startColumn": 38, + "endColumn": 42, "lineCount": 1 } }, { - "code": "reportImplicitOverride", + "code": "reportUnknownMemberType", "range": { - "startColumn": 8, - "endColumn": 15, + "startColumn": 55, + "endColumn": 68, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 37, - "endColumn": 53, + "startColumn": 55, + "endColumn": 68, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportUnknownVariableType", "range": { - "startColumn": 37, - "endColumn": 59, + "startColumn": 45, + "endColumn": 48, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 19, - "endColumn": 39, + "startColumn": 62, + "endColumn": 66, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 19, - "endColumn": 44, + "startColumn": 52, + "endColumn": 56, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 19, - "endColumn": 50, + "startColumn": 58, + "endColumn": 62, "lineCount": 1 } }, { - "code": "reportImplicitOverride", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 8, - "endColumn": 20, + "startColumn": 53, + "endColumn": 82, "lineCount": 1 } - }, + } + ], + "./arraycontext/pytest.py": [ { "code": "reportUnusedImport", "range": { @@ -10038,50 +9342,50 @@ } }, { - "code": "reportUnusedImport", + "code": "reportUnannotatedClassAttribute", "range": { - "startColumn": 19, + "startColumn": 4, "endColumn": 25, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportImplicitOverride", "range": { - "startColumn": 37, - "endColumn": 53, + "startColumn": 8, + "endColumn": 16, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportImplicitOverride", "range": { - "startColumn": 37, - "endColumn": 59, + "startColumn": 8, + "endColumn": 15, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportImplicitOverride", "range": { - "startColumn": 23, - "endColumn": 43, + "startColumn": 8, + "endColumn": 20, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportUnusedImport", "range": { - "startColumn": 23, - "endColumn": 48, + "startColumn": 19, + "endColumn": 27, "lineCount": 1 } }, { - "code": "reportUnknownMemberType", + "code": "reportUnusedImport", "range": { - "startColumn": 23, - "endColumn": 54, + "startColumn": 19, + "endColumn": 25, "lineCount": 1 } }, @@ -10261,22 +9565,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 24, - "endColumn": 33, - "lineCount": 1 - } - }, - { - "code": "reportUnknownLambdaType", - "range": { - "startColumn": 15, - "endColumn": 22, - "lineCount": 1 - } - }, { "code": "reportUnknownParameterType", "range": { @@ -10293,22 +9581,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 8, - "endColumn": 17, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 20, - "endColumn": 59, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -10317,38 +9589,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 20, - "endColumn": 23, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 8, - "endColumn": 22, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 39, - "endColumn": 52, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 20, - "endColumn": 28, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -10357,14 +9597,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 28, - "endColumn": 35, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -10373,78 +9605,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 24, - "endColumn": 31, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 8, - "endColumn": 24, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 34, - "endColumn": 17, - "lineCount": 4 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 22, - "endColumn": 58, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 41, - "endColumn": 45, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 20, - "endColumn": 28, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 23, - "endColumn": 39, - "lineCount": 1 - } - }, - { - "code": "reportUnknownLambdaType", - "range": { - "startColumn": 30, - "endColumn": 31, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 37, - "endColumn": 38, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -10462,16 +9622,6 @@ } } ], - "./arraycontext/typing.py": [ - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 20, - "endColumn": 30, - "lineCount": 1 - } - } - ], "./arraycontext/version.py": [ { "code": "reportUnusedParameter",