Skip to content

Commit 8ee6180

Browse files
committed
Address pre-commit findings concerning the use of tuple vs Tuple and List vs list in type hings, favoring list and tuple.
1 parent a135b49 commit 8ee6180

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/xdist/scheduler/isoscope.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def __init__(self, config: pytest.Config, log: xdist.remote.Producer):
144144
# is performed once the number of registered node collections reaches
145145
# `_expected_num_workers`. It is initialized to None and then updated
146146
# after validation succeeds.
147-
self._official_test_collection: Tuple[str, ...] | None = None
147+
self._official_test_collection: tuple[str, ...] | None = None
148148
# Remote worker node having `_official_test_collection` as its test
149149
# collection (for reporting failed collection validations)
150150
self._official_test_collection_node: WorkerController | None = None
@@ -184,7 +184,7 @@ def __init__(self, config: pytest.Config, log: xdist.remote.Producer):
184184
)
185185

186186
@property
187-
def nodes(self) -> List[WorkerController]:
187+
def nodes(self) -> list[WorkerController]:
188188
"""A new list of all active `WorkerController` nodes.
189189
190190
Called by xdist `DSession`.
@@ -536,7 +536,7 @@ def _reschedule_workers(self) -> None:
536536
"""Distribute work to workers if needed at this time."""
537537
assert self._state is not None
538538

539-
traversed_states: List[IsoScopeScheduling._State] = []
539+
traversed_states: list[IsoScopeScheduling._State] = []
540540
previous_state = None
541541
while self._state != previous_state:
542542
# NOTE: This loop will terminate because completion of tests and
@@ -764,7 +764,7 @@ def _handle_state_fence(self) -> None:
764764
self._log(f"Transitioned from {previous_state!s} to " f"{self._state!s}")
765765

766766
def _distribute_workset(
767-
self, workset: _ScopeWorkset, workers: List[_WorkerProxy]
767+
self, workset: _ScopeWorkset, workers: list[_WorkerProxy]
768768
) -> None:
769769
"""Distribute the tests in the given workset to the given workers.
770770
@@ -979,7 +979,7 @@ def _get_max_workers_for_num_tests(num_tests: int) -> int:
979979

980980
def _get_workers_available_for_distribution(
981981
self, scope_id: str
982-
) -> List[_WorkerProxy]:
982+
) -> list[_WorkerProxy]:
983983
"""Return workers available for distribution of the given Scope.
984984
985985
Available workers are non-shutting-down workers that either
@@ -1003,7 +1003,7 @@ def _get_workers_available_for_distribution(
10031003
)
10041004
]
10051005

1006-
def _get_workers_ready_for_fencing(self, scope_id: str) -> List[_WorkerProxy]:
1006+
def _get_workers_ready_for_fencing(self, scope_id: str) -> list[_WorkerProxy]:
10071007
"""Return workers that are ready to be Fenced for the given test Scope.
10081008
10091009
A worker that needs to be Fenced satisfies all the following conditions:
@@ -1028,9 +1028,9 @@ def _get_workers_ready_for_fencing(self, scope_id: str) -> List[_WorkerProxy]:
10281028
def _do_two_nodes_have_same_collection(
10291029
self,
10301030
reference_node: WorkerController,
1031-
reference_collection: Tuple[str, ...],
1031+
reference_collection: tuple[str, ...],
10321032
node: WorkerController,
1033-
collection: Tuple[str, ...],
1033+
collection: tuple[str, ...],
10341034
) -> bool:
10351035
"""
10361036
If collections differ, this method returns False while logging
@@ -1081,7 +1081,7 @@ def __init__(self, node: WorkerController):
10811081

10821082
# An ordered collection of test IDs collected by the remote worker.
10831083
# Initially None, until assigned by the Scheduler
1084-
self._collection: Tuple[str, ...] | None = None
1084+
self._collection: tuple[str, ...] | None = None
10851085

10861086
self._pending_test_by_index: OrderedDict[int, _TestProxy] = OrderedDict()
10871087

@@ -1094,15 +1094,15 @@ def node(self) -> WorkerController:
10941094
return self._node
10951095

10961096
@property
1097-
def collection(self) -> Tuple[str, ...] | None:
1097+
def collection(self) -> tuple[str, ...] | None:
10981098
"""
10991099
:return: An ordered collection of test IDs collected by the remote
11001100
worker; `None` if the collection is not available yet.
11011101
"""
11021102
return self._collection
11031103

11041104
@collection.setter
1105-
def collection(self, collection: Tuple[str, ...]) -> None:
1105+
def collection(self, collection: tuple[str, ...]) -> None:
11061106
"""
11071107
:param collection: An ordered collection of test IDs collected by the
11081108
remote worker. Must not be `None`. Also, MUST NOT be set already.
@@ -1211,7 +1211,7 @@ def handle_test_completion(self, test_index: int) -> None:
12111211
# Remove the test from the worker's pending queue
12121212
self._pending_test_by_index.pop(test_index)
12131213

1214-
def release_pending_tests(self) -> List[_TestProxy]:
1214+
def release_pending_tests(self) -> list[_TestProxy]:
12151215
"""Reset the worker's pending tests, returning those pending tests.
12161216
12171217
:return: A (possibly empty) list of pending tests.
@@ -1316,7 +1316,7 @@ def enqueue_test(self, test: _TestProxy) -> None:
13161316
# Update high watermark
13171317
self._high_water = max(self._high_water, len(self._test_by_index))
13181318

1319-
def dequeue_tests(self, num_tests: int) -> List[_TestProxy]:
1319+
def dequeue_tests(self, num_tests: int) -> list[_TestProxy]:
13201320
"""
13211321
Remove and return the given number of tests from the head of the
13221322
collection.

0 commit comments

Comments
 (0)