Skip to content

Commit 05b9494

Browse files
committed
all ruff checks should pass
1 parent a1dfb69 commit 05b9494

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

src/xdist/dsession.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
from queue import Empty
66
from queue import Queue
77
import sys
8+
import traceback
89
from typing import Any
910
from typing import Sequence
1011
import warnings
11-
import traceback
1212

1313
import execnet
1414
import pytest
1515

1616
from xdist.remote import Producer
1717
from xdist.remote import WorkerInfo
18+
from xdist.scheduler import CustomGroup
1819
from xdist.scheduler import EachScheduling
1920
from xdist.scheduler import LoadFileScheduling
2021
from xdist.scheduler import LoadGroupScheduling
2122
from xdist.scheduler import LoadScheduling
2223
from xdist.scheduler import LoadScopeScheduling
2324
from xdist.scheduler import Scheduling
2425
from xdist.scheduler import WorkStealingScheduling
25-
from xdist.scheduler import CustomGroup
2626
from xdist.workermanage import NodeManager
2727
from xdist.workermanage import WorkerController
2828

@@ -287,7 +287,9 @@ def worker_workerfinished(self, node: WorkerController) -> None:
287287
try:
288288
self.prepare_for_reschedule()
289289
except Exception as e:
290-
self.shouldstop = f"Exception caught during preparation for rescheduling. Giving up.\n{''.join(traceback.format_exception(e))}"
290+
msg = ("Exception caught during preparation for rescheduling. Giving up."
291+
f"\n{''.join(traceback.format_exception(e))}")
292+
self.shouldstop = msg
291293
return
292294
self.config.hook.pytest_testnodedown(node=node, error=None)
293295
if node.workeroutput["exitstatus"] == 2: # keyboard-interrupt
@@ -311,7 +313,8 @@ def worker_workerfinished(self, node: WorkerController) -> None:
311313
def update_worker_status(self, node, status):
312314
"""Track the worker status.
313315
314-
Can be used at callbacks like 'worker_workerfinished' so we remember wchic event was reported last by each worker.
316+
Can be used at callbacks like 'worker_workerfinished' so we remember wchic event
317+
was reported last by each worker.
315318
"""
316319
self.worker_status[node.workerinfo["id"]] = status
317320

src/xdist/scheduler/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from xdist.scheduler.customgroup import CustomGroup as CustomGroup
12
from xdist.scheduler.each import EachScheduling as EachScheduling
23
from xdist.scheduler.load import LoadScheduling as LoadScheduling
3-
from xdist.scheduler.customgroup import CustomGroup as CustomGroup
44
from xdist.scheduler.loadfile import LoadFileScheduling as LoadFileScheduling
55
from xdist.scheduler.loadgroup import LoadGroupScheduling as LoadGroupScheduling
66
from xdist.scheduler.loadscope import LoadScopeScheduling as LoadScopeScheduling

src/xdist/scheduler/customgroup.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import annotations
22

33
from itertools import cycle
4-
from typing import Sequence, Any
4+
from typing import Any
5+
from typing import Sequence
56

67
import pytest
78

@@ -10,6 +11,7 @@
1011
from xdist.workermanage import parse_spec_config
1112
from xdist.workermanage import WorkerController
1213

14+
1315
class CustomGroup:
1416
"""Implement grouped load scheduling across a variable number of nodes.
1517
@@ -235,13 +237,16 @@ def check_schedule(self, node: WorkerController, duration: float = 0, from_dsess
235237

236238
self._send_tests_group(n, 1, dist_group_key)
237239
del self.dist_groups[dist_group_key]
238-
message = f"\n[-] [csg] check_schedule: processed scheduling for {dist_group_key}: {' '.join([f'{nid} ({len(nt)})' for nid,nt in schedule_log.items()])}"
240+
message = (f"\n[-] [csg] check_schedule: processed scheduling for {dist_group_key}:"
241+
f" {' '.join([f'{nid} ({len(nt)})' for nid,nt in schedule_log.items()])}")
239242
self.report_line(message)
240243

241244
else:
242245
pending = self.node2pending.get(node)
243246
if len(pending) < 2:
244-
self.report_line(f"[-] [csg] Shutting down {node.workerinput['workerid']} because only one case is pending")
247+
self.report_line(
248+
f"[-] [csg] Shutting down {node.workerinput['workerid']} because only one case is pending"
249+
)
245250
node.shutdown()
246251

247252
self.log("num items waiting for node:", len(self.pending))
@@ -346,7 +351,8 @@ def schedule(self) -> None:
346351
schedule_log[n.gateway.id].extend(tests_per_node)
347352
self._send_tests_group(n, 1, dist_group_key)
348353
del self.dist_groups[dist_group_key]
349-
message = f"\n[-] [csg] schedule: processed scheduling for {dist_group_key}: {' '.join([f'{nid} ({len(nt)})' for nid, nt in schedule_log.items()])}"
354+
message = ("\n[-] [csg] schedule: processed scheduling for "
355+
f"{dist_group_key}: {' '.join([f'{nid} ({len(nt)})' for nid, nt in schedule_log.items()])}")
350356
self.report_line(message)
351357

352358
def _send_tests(self, node: WorkerController, num: int) -> None:
@@ -396,4 +402,4 @@ def _check_nodes_have_same_collection(self) -> bool:
396402

397403
def report_line(self, line: str) -> None:
398404
if self.terminal and self.config.option.verbose >= 0:
399-
self.terminal.write_line(line)
405+
self.terminal.write_line(line)

src/xdist/workermanage.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from typing import Literal
1212
from typing import Sequence
1313
from typing import Union
14-
from typing import Optional
1514
import uuid
1615
import warnings
1716

@@ -83,7 +82,7 @@ def rsync_roots(self, gateway: execnet.Gateway) -> None:
8382
def setup_nodes(
8483
self,
8584
putevent: Callable[[tuple[str, dict[str, Any]]], None],
86-
max_nodes: Optional[int] = None
85+
max_nodes: int | None = None
8786
) -> list[WorkerController]:
8887
self.config.hook.pytest_xdist_setupnodes(config=self.config, specs=self.specs)
8988
self.trace("setting up nodes")

xdist-testing-ntop/test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import pytest
21
import time
32

3+
import pytest
4+
45

56
@pytest.mark.xdist_custom(name="low_4")
67
def test_1():

0 commit comments

Comments
 (0)