Skip to content

Commit 4af2d0a

Browse files
Miscellaneous flake8-bugbear issues (#6814)
1 parent ad65a54 commit 4af2d0a

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

distributed/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,8 @@ def __init__(
836836
elif isinstance(getattr(address, "scheduler_address", None), str):
837837
# It's a LocalCluster or LocalCluster-compatible object
838838
self.cluster = address
839-
status = getattr(self.cluster, "status")
840-
if status and status in [Status.closed, Status.closing]:
839+
status = self.cluster.status
840+
if status in (Status.closed, Status.closing):
841841
raise RuntimeError(
842842
f"Trying to connect to an already closed or closing Cluster {self.cluster}."
843843
)

distributed/comm/addressing.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@ def address_from_user_args( # type: ignore[no-untyped-def]
272272
if security and security.require_encryption and not protocol:
273273
protocol = "tls"
274274

275-
if protocol and protocol.rstrip("://") == "inplace":
275+
if protocol and protocol.endswith("://"):
276+
protocol, _, _ = protocol.rpartition("://")
277+
278+
if protocol == "inplace":
276279
if host or port or interface:
277280
raise ValueError(
278281
"Can not specify inproc protocol and host or port or interface"
@@ -287,14 +290,14 @@ def address_from_user_args( # type: ignore[no-untyped-def]
287290
host = get_ip_interface(interface)
288291

289292
if protocol and host and "://" not in host:
290-
host = protocol.rstrip("://") + "://" + host
293+
host = protocol + "://" + host
291294

292295
if host or port:
293296
addr = uri_from_host_port(host, port, default_port)
294297
else:
295298
addr = ""
296299

297300
if protocol:
298-
addr = protocol.rstrip("://") + "://" + addr.split("://")[-1]
301+
addr = protocol + "://" + addr.split("://")[-1]
299302

300303
return addr

distributed/tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3866,8 +3866,8 @@ def test_get_versions_sync(c):
38663866
assert v["scheduler"] is not None
38673867
assert v["client"] is not None
38683868
assert len(v["workers"]) == 2
3869-
for v in v["workers"].values():
3870-
assert v is not None
3869+
for wv in v["workers"].values():
3870+
assert wv is not None
38713871

38723872
c.get_versions(check=True)
38733873
# smoke test for versions

distributed/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ def command_has_keyword(cmd, k):
12271227
except ImportError:
12281228
raise ImportError("Module for command %s is not available" % cmd)
12291229

1230-
if isinstance(getattr(cmd, "main"), click.core.Command):
1230+
if isinstance(cmd.main, click.core.Command):
12311231
cmd = cmd.main
12321232
if isinstance(cmd, click.core.Command):
12331233
cmd_params = {

distributed/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ async def _force_close(self):
212212
await asyncio.wait_for(self.close(nanny=False, executor_wait=False), 30)
213213
except (KeyboardInterrupt, SystemExit): # pragma: nocover
214214
raise
215-
except (Exception, BaseException): # pragma: nocover
215+
except BaseException: # pragma: nocover
216216
# Worker is in a very broken state if closing fails. We need to shut down
217217
# immediately, to ensure things don't get even worse and this worker potentially
218218
# deadlocks the cluster.

0 commit comments

Comments
 (0)