Skip to content

Commit 5808348

Browse files
committed
[FIX] Fix mypy errors.
1 parent badd083 commit 5808348

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/xdist/scheduler/singlecollect.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
class SingleCollectScheduling:
1414
"""Implement scheduling with a single test collection phase.
15-
15+
1616
This differs from LoadScheduling by:
1717
1. Only collecting tests on the first node
1818
2. Skipping collection on other nodes
1919
3. Not checking for collection equality
20-
20+
2121
This can significantly improve startup time by avoiding redundant collection
2222
and collection verification across multiple worker processes.
2323
"""
@@ -72,7 +72,7 @@ def add_node(self, node: WorkerController) -> None:
7272
"""Add a new node to the scheduler."""
7373
assert node not in self.node2pending
7474
self.node2pending[node] = []
75-
75+
7676
# Remember the first node as our collector
7777
if self.first_node is None:
7878
self.first_node = node
@@ -92,10 +92,10 @@ def add_node_collection(
9292
self.log(f"Ignoring collection from node {node.gateway.id}")
9393

9494
def mark_test_complete(
95-
self, node: WorkerController, item_index: int, duration: float = 0
95+
self, node: WorkerController, item_index: int | str, duration: float = 0
9696
) -> None:
9797
"""Mark test item as completed by node."""
98-
self.node2pending[node].remove(item_index)
98+
self.node2pending[node].remove(int(item_index) if isinstance(item_index, str) else item_index)
9999
self.check_schedule(node, duration=duration)
100100

101101
def mark_test_pending(self, item: str) -> None:
@@ -145,11 +145,11 @@ def check_schedule(self, node: WorkerController, duration: float = 0) -> None:
145145
def remove_node(self, node: WorkerController) -> str | None:
146146
"""Remove a node from the scheduler."""
147147
pending = self.node2pending.pop(node)
148-
148+
149149
# If this is the first node (collector), reset it
150150
if node == self.first_node:
151151
self.first_node = None
152-
152+
153153
if not pending:
154154
return None
155155

testing/acceptance_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ def test_singlecollect_handles_fixtures(self, pytester: pytest.Pytester) -> None
6060
pytester.makepyfile(
6161
"""
6262
import pytest
63-
63+
6464
@pytest.fixture
6565
def my_fixture():
6666
return 42
67-
6867
def test_with_fixture(my_fixture):
6968
assert my_fixture == 42
7069
"""

testing/test_dsession.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ def test_handle_node_failure(self, pytester: pytest.Pytester) -> None:
544544
sched.mark_test_complete(node1, test_idx)
545545

546546
# Now remove node2 (simulating failure)
547-
crashitem = sched.remove_node(node2)
547+
sched.remove_node(node2)
548548

549549
# Tests assigned to node2 should go back to pending
550550
assert len(sched.pending) > 0
@@ -590,6 +590,7 @@ def test_first_node_failure(self, pytester: pytest.Pytester) -> None:
590590
# Add a new node, it should become the collector
591591
node3 = MockNode()
592592
sched.add_node(node3)
593+
# Verify the new node became the collector
593594
assert sched.first_node == node3
594595

595596
# Complete collection with node3

0 commit comments

Comments
 (0)