From 58e360eeb66a788dde8346342b8dbac84b8fb4e7 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sun, 18 Feb 2024 16:22:16 -0600 Subject: [PATCH] fix typing --- jupyter_client/session.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jupyter_client/session.py b/jupyter_client/session.py index 1caf9634..c1a48470 100644 --- a/jupyter_client/session.py +++ b/jupyter_client/session.py @@ -818,7 +818,7 @@ async def send_multipart(*args, **kwargs): return await stream.send_multipart(*args, **kwargs) send_func = run_sync(send_multipart) - else: + elif stream is not None: send_func = stream.send_multipart if isinstance(msg_or_type, (Message, dict)): @@ -861,7 +861,7 @@ async def send_multipart(*args, **kwargs): longest = max([len(s) for s in to_send]) copy = longest < self.copy_threshold - if stream and buffers and track and not copy: + if stream is not None and buffers and track and not copy: # only really track when we are doing zero-copy buffers tracker = send_func(to_send, copy=False, track=True) elif stream: @@ -914,10 +914,10 @@ def send_raw( to_send.append(self.sign(msg_list[0:4])) to_send.extend(msg_list) if isinstance(stream, zmq.asyncio.Socket): - assert stream is not None # type:ignore[unreachable] + assert stream is not None - async def send_multipart(*args, **kwargs): - return await stream.send_multipart(*args, **kwargs) + async def send_multipart(*args: t.Any, **kwargs: t.Any) -> None: + await stream.send_multipart(*args, **kwargs) send_func = run_sync(send_multipart) else: @@ -949,7 +949,7 @@ def recv( if isinstance(socket, zmq.asyncio.Socket): - async def recv_multipart(*args, **kwargs): + async def recv_multipart(*args: t.Any, **kwargs: t.Any) -> t.Any: return await socket.recv_multipart(*args, **kwargs) recv_func = run_sync(recv_multipart)