Skip to content

Commit 8b69384

Browse files
Bump ty from 0.0.14 to 0.0.17 (#794)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tobias Raabe <raabe@posteo.de>
1 parent 05a40e1 commit 8b69384

6 files changed

Lines changed: 55 additions & 32 deletions

File tree

src/_pytask/coiled_utils.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,51 @@
33
from dataclasses import dataclass
44
from typing import TYPE_CHECKING
55
from typing import Any
6+
from typing import cast
67

78
if TYPE_CHECKING:
89
from collections.abc import Callable
10+
from typing import Protocol
911

1012
try:
1113
from coiled.function import Function
1214
except ImportError:
1315

1416
@dataclass
1517
class Function:
16-
cluster_kwargs: dict[str, Any]
17-
environ: dict[str, Any]
18+
_cluster_kwargs: dict[str, Any]
19+
_environ: dict[str, Any] | None
20+
_local: bool
21+
_name: str
1822
function: Callable[..., Any] | None
19-
keepalive: str | None
23+
keepalive: Any | None
2024

2125

2226
__all__ = ["Function"]
2327

2428

29+
if TYPE_CHECKING:
30+
31+
class _CoiledFunctionPrivateAttrs(Protocol):
32+
_cluster_kwargs: dict[str, Any]
33+
_environ: dict[str, Any] | None
34+
_local: bool
35+
_name: str
36+
keepalive: Any | None
37+
38+
39+
def _as_coiled_private_attrs(func: Function) -> _CoiledFunctionPrivateAttrs:
40+
"""Cast to the private-attribute layout used by coiled's Function class."""
41+
return cast("_CoiledFunctionPrivateAttrs", func)
42+
43+
2544
def extract_coiled_function_kwargs(func: Function) -> dict[str, Any]:
2645
"""Extract the kwargs for a coiled function."""
46+
coiled_function = _as_coiled_private_attrs(func)
2747
return {
28-
"cluster_kwargs": func._cluster_kwargs, # ty: ignore[possibly-missing-attribute]
29-
"keepalive": func.keepalive,
30-
"environ": func._environ, # ty: ignore[possibly-missing-attribute]
31-
"local": func._local, # ty: ignore[possibly-missing-attribute]
32-
"name": func._name, # ty: ignore[possibly-missing-attribute]
48+
"cluster_kwargs": coiled_function._cluster_kwargs,
49+
"keepalive": coiled_function.keepalive,
50+
"environ": coiled_function._environ,
51+
"local": coiled_function._local,
52+
"name": coiled_function._name,
3353
}

src/_pytask/path.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ def _import_module_using_spec(
331331
break
332332
else:
333333
spec = importlib.util.spec_from_file_location(module_name, str(module_path))
334-
if spec is not None:
334+
if spec is not None and spec.loader is not None:
335335
mod = importlib.util.module_from_spec(spec)
336336
sys.modules[module_name] = mod
337-
spec.loader.exec_module(mod) # ty: ignore[possibly-missing-attribute]
337+
spec.loader.exec_module(mod)
338338
_insert_missing_modules(sys.modules, module_name)
339339
return mod
340340

src/_pytask/task_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def wrapper(func: T) -> TaskDecorated[T]:
186186

187187
# When decorator is used without parentheses, call wrapper directly.
188188
if is_task_function(name) and kwargs is None:
189-
return wrapper(cast("T", name))
189+
return wrapper(cast("T", name)) # ty: ignore[invalid-argument-type]
190190
return wrapper
191191

192192

tests/test_collect.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from _pytask.collect import _find_shortest_uniquely_identifiable_name_for_tasks
1212
from _pytask.collect import pytask_collect_node
13+
from _pytask.node_protocols import PPathNode
1314
from pytask import CollectionOutcome
1415
from pytask import ExitCode
1516
from pytask import NodeInfo
@@ -237,6 +238,7 @@ def test_pytask_collect_node_does_not_raise_error_if_path_is_not_normalized(
237238
)
238239
assert not record
239240

241+
assert isinstance(result, PPathNode)
240242
assert str(result.path) == str(real_node)
241243

242244

tests/test_dag_command.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import importlib
34
import os
45
import subprocess
56
import sys
@@ -12,7 +13,7 @@
1213
from pytask import cli
1314

1415
try:
15-
import pygraphviz # type: ignore[unresolved-import] # noqa: F401
16+
importlib.import_module("pygraphviz")
1617
except ImportError: # pragma: no cover
1718
_IS_PYGRAPHVIZ_INSTALLED = False
1819
else:

uv.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)