From 1247b2b5bbdd3527c08e01ed5fe202fd7d1ec2e1 Mon Sep 17 00:00:00 2001 From: crusaderky Date: Thu, 30 Apr 2026 16:11:43 +0100 Subject: [PATCH] Clean up deprecated `stream` RPC handler argument --- distributed/core.py | 18 +++++------------- distributed/tests/test_core.py | 14 -------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/distributed/core.py b/distributed/core.py index 9309aaabe71..07fd7d3f025 100644 --- a/distributed/core.py +++ b/distributed/core.py @@ -124,19 +124,11 @@ def _raise(*args, **kwargs): @functools.cache def _expects_comm(func: Callable) -> bool: - sig = inspect.signature(func) - params = list(sig.parameters) - if params and params[0] == "comm": - return True - if params and params[0] == "stream": - warnings.warn( - "Calling the first argument of a RPC handler `stream` is " - "deprecated. Defining this argument is optional. Either remove the " - f"argument or rename it to `comm` in {func}.", - FutureWarning, - ) - return True - return False + """Return True if func expects a first argument named 'comm'; + False otherwise. + """ + params = inspect.signature(func).parameters + return bool(params) and next(iter(params)) == "comm" class Server: diff --git a/distributed/tests/test_core.py b/distributed/tests/test_core.py index 78768f4bdde..9ca49ad36cd 100644 --- a/distributed/tests/test_core.py +++ b/distributed/tests/test_core.py @@ -1253,41 +1253,27 @@ def one_arg(self, arg): ... def comm_arg(self, comm): ... - def stream_arg(self, stream): ... - def two_arg(self, arg, other): ... def comm_arg_other(self, comm, other): ... - def stream_arg_other(self, stream, other): ... - def arg_kwarg(self, arg, other=None): ... def comm_posarg_only(self, comm, /, other): ... def comm_not_leading_position(self, other, comm): ... - def stream_not_leading_position(self, other, stream): ... - - expected_warning = "first argument of a RPC handler `stream` is deprecated" - instance = A() assert not _expects_comm(instance.empty) assert not _expects_comm(instance.one_arg) assert _expects_comm(instance.comm_arg) - with pytest.warns(FutureWarning, match=expected_warning): - assert _expects_comm(instance.stream_arg) assert not _expects_comm(instance.two_arg) assert _expects_comm(instance.comm_arg_other) - with pytest.warns(FutureWarning, match=expected_warning): - assert _expects_comm(instance.stream_arg_other) assert not _expects_comm(instance.arg_kwarg) assert _expects_comm(instance.comm_posarg_only) assert not _expects_comm(instance.comm_not_leading_position) - assert not _expects_comm(instance.stream_not_leading_position) - class AsyncStopTCPListener(TCPListener): async def stop(self):