Skip to content

Commit db5154c

Browse files
committed
Fixes for new typing failures
1 parent 75802d1 commit db5154c

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

arraycontext/impl/pytato/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ def _to_frozen(
653653
transformed_dag = self.transform_dag(normalized_expr)
654654

655655
from pytato.tags import PrefixNamed
656-
name_hint_tags = []
656+
name_hint_tags: list[PrefixNamed] = []
657657
for subary in key_to_pt_arrays.values():
658658
name_hint_tags.extend(subary.tags_of_type(PrefixNamed))
659659

arraycontext/pytest.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
THE SOFTWARE.
3434
"""
3535

36-
from typing import TYPE_CHECKING, Any
36+
from typing import TYPE_CHECKING, Any, cast
3737

3838
from typing_extensions import override
3939

@@ -43,6 +43,8 @@
4343
if TYPE_CHECKING:
4444
from collections.abc import Callable, Sequence
4545

46+
import pyopencl as cl
47+
4648
from arraycontext.context import ArrayContext
4749

4850

@@ -62,14 +64,16 @@ class PytestPyOpenCLArrayContextFactory(PytestArrayContextFactory):
6264
.. automethod:: __init__
6365
.. automethod:: __call__
6466
"""
67+
device: cl.Device
6568

66-
def __init__(self, device):
69+
def __init__(self, device: cl.Device):
6770
"""
6871
:arg device: a :class:`pyopencl.Device`.
6972
"""
7073
self.device = device
7174

7275
@classmethod
76+
@override
7377
def is_available(cls) -> bool:
7478
try:
7579
import pyopencl # noqa: F401
@@ -384,7 +388,10 @@ def inner(metafunc):
384388
if pyopencl_factories:
385389
for arg_dict in arg_values:
386390
arg_values_with_actx.extend([
387-
{factory_arg_name: factory(arg_dict["device"]), **arg_dict}
391+
{factory_arg_name: cast(
392+
"type[PytestPyOpenCLArrayContextFactory]",
393+
factory)(cast("cl.Device", arg_dict["device"])),
394+
**arg_dict}
388395
for factory in pyopencl_factories
389396
])
390397

doc/conf.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,12 @@
4646
["py:class", r"np.integer"],
4747
["py:class", r".*\|.*"],
4848
]
49+
50+
sphinxconfig_missing_reference_aliases = {
51+
# pyopencl
52+
"cl.Device": "obj:pyopencl.Device",
53+
}
54+
55+
56+
def setup(app):
57+
app.connect("missing-reference", process_autodoc_missing_reference) # noqa: F821

0 commit comments

Comments
 (0)