Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous flake8-bugbear issues #6814

Merged
merged 3 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion distributed/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def __init__(
elif isinstance(getattr(address, "scheduler_address", None), str):
# It's a LocalCluster or LocalCluster-compatible object
self.cluster = address
status = getattr(self.cluster, "status")
status = self.cluster.status
if status and status in [Status.closed, Status.closing]:
crusaderky marked this conversation as resolved.
Show resolved Hide resolved
raise RuntimeError(
f"Trying to connect to an already closed or closing Cluster {self.cluster}."
Expand Down
9 changes: 6 additions & 3 deletions distributed/comm/addressing.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ def address_from_user_args( # type: ignore[no-untyped-def]
if security and security.require_encryption and not protocol:
protocol = "tls"

if protocol and protocol.rstrip("://") == "inplace":
if protocol and protocol.endswith("://"):
protocol, _, _ = protocol.rpartition("://")

if protocol == "inplace":
if host or port or interface:
raise ValueError(
"Can not specify inproc protocol and host or port or interface"
Expand All @@ -287,14 +290,14 @@ def address_from_user_args( # type: ignore[no-untyped-def]
host = get_ip_interface(interface)

if protocol and host and "://" not in host:
host = protocol.rstrip("://") + "://" + host
host = protocol + "://" + host

if host or port:
addr = uri_from_host_port(host, port, default_port)
else:
addr = ""

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

return addr
4 changes: 2 additions & 2 deletions distributed/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3866,8 +3866,8 @@ def test_get_versions_sync(c):
assert v["scheduler"] is not None
assert v["client"] is not None
assert len(v["workers"]) == 2
for v in v["workers"].values():
assert v is not None
for wv in v["workers"].values():
assert wv is not None

c.get_versions(check=True)
# smoke test for versions
Expand Down
2 changes: 1 addition & 1 deletion distributed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ def command_has_keyword(cmd, k):
except ImportError:
raise ImportError("Module for command %s is not available" % cmd)

if isinstance(getattr(cmd, "main"), click.core.Command):
if isinstance(cmd.main, click.core.Command):
cmd = cmd.main
if isinstance(cmd, click.core.Command):
cmd_params = {
Expand Down
2 changes: 1 addition & 1 deletion distributed/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ async def _force_close(self):
await asyncio.wait_for(self.close(nanny=False, executor_wait=False), 30)
except (KeyboardInterrupt, SystemExit): # pragma: nocover
raise
except (Exception, BaseException): # pragma: nocover
except BaseException: # pragma: nocover
# Worker is in a very broken state if closing fails. We need to shut down
# immediately, to ensure things don't get even worse and this worker potentially
# deadlocks the cluster.
Expand Down