Use ruff instead of black, flake8, autoflake, pyupgrade

Config adapted from pytest.
This commit is contained in:
Ran Benita
2024-04-02 23:23:31 +03:00
parent c01de1c73e
commit 816c9dcda1
15 changed files with 109 additions and 73 deletions

View File

@@ -243,7 +243,7 @@ class LoadScheduling:
return
# Collections are identical, create the index of pending items.
self.collection = list(self.node2collection.values())[0]
self.collection = next(iter(self.node2collection.values()))
self.pending[:] = range(len(self.collection))
if not self.collection:
return
@@ -260,7 +260,7 @@ class LoadScheduling:
# to each node - which is suboptimal when you have less than
# 2 * len(nodes) tests.
nodes = cycle(self.nodes)
for i in range(len(self.pending)):
for _ in range(len(self.pending)):
self._send_tests(next(nodes), 1)
else:
# Send batches of consecutive tests. By default, pytest sorts tests

View File

@@ -208,7 +208,6 @@ class LoadScopeScheduling:
- ``DSession.worker_collectionfinish``.
"""
# Check that add_node() was called on the node before
assert node in self.assigned_work
@@ -301,7 +300,6 @@ class LoadScopeScheduling:
If there are any globally pending work units left then this will check
if the given node should be given any more tests.
"""
# Do not add more work to a node shutting down
if node.shutting_down:
return

View File

@@ -1,4 +1,7 @@
from collections import namedtuple
from __future__ import annotations
from typing import Any
from typing import NamedTuple
from _pytest.runner import CollectReport
@@ -7,7 +10,10 @@ from xdist.report import report_collection_diff
from xdist.workermanage import parse_spec_config
NodePending = namedtuple("NodePending", ["node", "pending"])
class NodePending(NamedTuple):
node: Any
pending: list[int]
# Every worker needs at least 2 tests in queue - the current and the next one.
MIN_PENDING = 2
@@ -285,7 +291,7 @@ class WorkStealingScheduling:
return
# Collections are identical, create the index of pending items.
self.collection = list(self.node2collection.values())[0]
self.collection = next(iter(self.node2collection.values()))
self.pending[:] = range(len(self.collection))
if not self.collection:
return