Skip to content

Commit 8ea6da5

Browse files
eleanorjboydCopilot
andcommitted
Fix pyright errors in test_discovery.py
Cast dict literal to TestNode and list children to List[Any] so pyright accepts dict/list usage where the TypedDict declares Children. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2840fd5 commit 8ea6da5

1 file changed

Lines changed: 29 additions & 26 deletions

File tree

python_files/tests/pytestadapter/test_discovery.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,41 @@ def test_compact_discovery_payload_keeps_absolute_tree_until_return(tmp_path, mo
1919
base_path = tmp_path / "workspace"
2020
test_file = base_path / "tests" / "test_sample.py"
2121
absolute_test_id = f"{os.fspath(test_file)}::test_case[param]"
22-
session_node: vscode_pytest.TestNode = {
23-
"name": "workspace",
24-
"path": base_path,
25-
"type_": "folder",
26-
"id_": os.fspath(base_path),
27-
"children": [
28-
{
29-
"name": "test_sample.py",
30-
"path": test_file,
31-
"type_": "file",
32-
"id_": os.fspath(test_file),
33-
"children": [
34-
{
35-
"name": "test_case[param]",
36-
"path": test_file,
37-
"type_": "test",
38-
"id_": absolute_test_id,
39-
"runID": absolute_test_id,
40-
"lineno": "7",
41-
}
42-
],
43-
}
44-
],
45-
}
22+
session_node = cast(
23+
"vscode_pytest.TestNode",
24+
{
25+
"name": "workspace",
26+
"path": base_path,
27+
"type_": "folder",
28+
"id_": os.fspath(base_path),
29+
"children": [
30+
{
31+
"name": "test_sample.py",
32+
"path": test_file,
33+
"type_": "file",
34+
"id_": os.fspath(test_file),
35+
"children": [
36+
{
37+
"name": "test_case[param]",
38+
"path": test_file,
39+
"type_": "test",
40+
"id_": absolute_test_id,
41+
"runID": absolute_test_id,
42+
"lineno": "7",
43+
}
44+
],
45+
}
46+
],
47+
},
48+
)
4649

4750
payload = vscode_pytest.create_compact_discovery_payload(os.fspath(base_path), session_node)
4851

4952
assert session_node["path"] == base_path
50-
file_node = cast("vscode_pytest.TestNode", session_node["children"][0])
53+
file_node = cast("vscode_pytest.TestNode", cast("List[Any]", session_node["children"])[0])
5154
assert file_node is not None
5255
assert file_node["path"] == test_file
53-
test_node = cast("vscode_pytest.TestItem", file_node["children"][0])
56+
test_node = cast("vscode_pytest.TestItem", cast("List[Any]", file_node["children"])[0])
5457
assert test_node is not None
5558
assert test_node["id_"] == absolute_test_id
5659

0 commit comments

Comments
 (0)