Skip to content

Commit fa103f1

Browse files
committed
fix: tell ty the dask imports are allowed to be unresolvable
dask is the parallel extra, so uv sync --frozen does not install it and ty cannot resolve it. Suppressed at all four sites rather than added to the dev group: that is what pyproject does for mcp, but it would install dask into every job to type check the one function allowed to run without it.
1 parent 3fe98e4 commit fa103f1

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎src/osw/utils/util.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,13 @@ def async_parallelize(func: Callable, iterable: Iterable, **kwargs):
591591
by core, wtsite and wiki_tools - which rules out Pyodide, where there is no
592592
dask build at all.
593593
"""
594-
import dask
595-
from dask.diagnostics import ProgressBar
594+
# ty cannot resolve these: dask is the `parallel` extra and is deliberately
595+
# absent from the dev environment, which is the condition this import exists to
596+
# tolerate. Adding the extra to the dev group would make it resolve - that is what
597+
# pyproject does for mcp - but it would install dask everywhere to type check the
598+
# one place that is allowed to run without it.
599+
import dask # ty: ignore[unresolved-import]
600+
from dask.diagnostics import ProgressBar # ty: ignore[unresolved-import]
596601

597602
async def inner(func_, iterable_, **kwargs_):
598603
async with AsyncMessageBuffer() as msg_buf:
@@ -655,8 +660,8 @@ def wrapped_function(*args, **kwargs):
655660

656661
# Only the demo helpers below use dask; see async_parallelize for why it is
657662
# not imported at module scope. Needs the optional `parallel` extra.
658-
import dask
659-
from dask.diagnostics import ProgressBar
663+
import dask # ty: ignore[unresolved-import]
664+
from dask.diagnostics import ProgressBar # ty: ignore[unresolved-import]
660665

661666
print("Redirecting print messages to a buffer.")
662667
message_buffer = MessageBuffer()

0 commit comments

Comments
 (0)