|
17 | 17 | import warnings |
18 | 18 | import weakref |
19 | 19 | from collections import defaultdict |
20 | | -from collections.abc import Collection, Coroutine, Iterable, Iterator, Sequence |
| 20 | +from collections.abc import ( |
| 21 | + Callable, |
| 22 | + Collection, |
| 23 | + Coroutine, |
| 24 | + Iterable, |
| 25 | + Iterator, |
| 26 | + Sequence, |
| 27 | +) |
21 | 28 | from concurrent.futures import ThreadPoolExecutor |
22 | 29 | from concurrent.futures._base import DoneAndNotDoneFutures |
23 | 30 | from contextlib import asynccontextmanager, contextmanager, suppress |
|
29 | 36 | from typing import ( |
30 | 37 | TYPE_CHECKING, |
31 | 38 | Any, |
32 | | - Callable, |
33 | 39 | ClassVar, |
34 | 40 | Generic, |
35 | 41 | Literal, |
|
125 | 131 | from distributed.worker import get_client, get_worker, secede |
126 | 132 |
|
127 | 133 | if TYPE_CHECKING: |
128 | | - from typing_extensions import TypeAlias |
| 134 | + from typing import TypeAlias |
129 | 135 |
|
130 | 136 | logger = logging.getLogger(__name__) |
131 | 137 |
|
@@ -1121,9 +1127,7 @@ def __init__( |
1121 | 1127 | security = getattr(self.cluster, "security", None) |
1122 | 1128 | elif address is not None and not isinstance(address, str): |
1123 | 1129 | raise TypeError( |
1124 | | - "Scheduler address must be a string or a Cluster instance, got {}".format( |
1125 | | - type(address) |
1126 | | - ) |
| 1130 | + f"Scheduler address must be a string or a Cluster instance, got {type(address)}" |
1127 | 1131 | ) |
1128 | 1132 |
|
1129 | 1133 | # If connecting to an address and no explicit security is configured, attempt |
@@ -1375,10 +1379,7 @@ def __repr__(self): |
1375 | 1379 | return text |
1376 | 1380 |
|
1377 | 1381 | elif self.scheduler is not None: |
1378 | | - return "<{}: scheduler={!r}>".format( |
1379 | | - self.__class__.__name__, |
1380 | | - self.scheduler.address, |
1381 | | - ) |
| 1382 | + return f"<{self.__class__.__name__}: scheduler={self.scheduler.address!r}>" |
1382 | 1383 | else: |
1383 | 1384 | return f"<{self.__class__.__name__}: No scheduler connected>" |
1384 | 1385 |
|
@@ -2368,7 +2369,7 @@ async def _gather(self, futures, errors="raise", direct=None, local_worker=None) |
2368 | 2369 | "Cannot gather Futures created by another client. " |
2369 | 2370 | f"These are the {len(mismatched_futures)} (out of {len(futures)}) " |
2370 | 2371 | f"mismatched Futures and their client IDs (this client is {self.id}): " |
2371 | | - f"{ {f: f.client.id for f in mismatched_futures} }" # noqa: E201, E202 |
| 2372 | + f"{ {f: f.client.id for f in mismatched_futures} }" |
2372 | 2373 | ) |
2373 | 2374 | keys = [future.key for future in future_set] |
2374 | 2375 | bad_data = dict() |
@@ -5892,8 +5893,8 @@ def count(self): |
5892 | 5893 | return len(self.futures) + len(self.queue.queue) |
5893 | 5894 |
|
5894 | 5895 | def __repr__(self): |
5895 | | - return "<as_completed: waiting={} done={}>".format( |
5896 | | - len(self.futures), len(self.queue.queue) |
| 5896 | + return ( |
| 5897 | + f"<as_completed: waiting={len(self.futures)} done={len(self.queue.queue)}>" |
5897 | 5898 | ) |
5898 | 5899 |
|
5899 | 5900 | def __iter__(self): |
|
0 commit comments