Skip to content

Commit 5f5683e

Browse files
committed
Fix typing in lockfile state tests
1 parent e1bb859 commit 5f5683e

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

tests/test_database.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from _pytask.lockfile import build_portable_node_id
66
from _pytask.lockfile import build_portable_task_id
77
from _pytask.lockfile import read_lockfile
8+
from _pytask.node_protocols import PNode
9+
from _pytask.tree_util import tree_leaves
810
from pytask import ExitCode
911
from pytask import build
1012
from pytask import cli
@@ -40,8 +42,14 @@ def task_write(path=Path("in.txt"), produces=Path("out.txt")):
4042
produces = task.produces
4143
assert depends_on is not None
4244
assert produces is not None
43-
in_node = depends_on["path"] # type: ignore[union-attr]
44-
out_node = produces["produces"] # type: ignore[union-attr]
45+
in_nodes = tree_leaves(depends_on["path"])
46+
out_nodes = tree_leaves(produces["produces"])
47+
assert len(in_nodes) == 1
48+
assert len(out_nodes) == 1
49+
in_node = in_nodes[0]
50+
out_node = out_nodes[0]
51+
assert isinstance(in_node, PNode)
52+
assert isinstance(out_node, PNode)
4553

4654
in_id = build_portable_node_id(in_node, tmp_path)
4755
out_id = build_portable_node_id(out_node, tmp_path)

tests/test_persist.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
from _pytask.lockfile import build_portable_node_id
99
from _pytask.lockfile import build_portable_task_id
1010
from _pytask.lockfile import read_lockfile
11+
from _pytask.node_protocols import PNode
1112
from _pytask.persist import pytask_execute_task_process_report
13+
from _pytask.tree_util import tree_leaves
1214
from pytask import ExitCode
1315
from pytask import Persisted
1416
from pytask import SkippedUnchanged
@@ -69,7 +71,10 @@ def task_dummy(path=Path("in.txt"), produces=Path("out.txt")):
6971
entry = tasks_by_id[build_portable_task_id(task, tmp_path)]
7072
produces = task.produces
7173
assert produces is not None
72-
node = produces["produces"] # type: ignore[union-attr]
74+
nodes = tree_leaves(produces["produces"])
75+
assert len(nodes) == 1
76+
node = nodes[0]
77+
assert isinstance(node, PNode)
7378
node_id = build_portable_node_id(node, tmp_path)
7479
assert entry.produces[node_id] == node.state()
7580

0 commit comments

Comments
 (0)