Skip to content

Commit 82f90ac

Browse files
committed
fix mypy lints
1 parent e6646e7 commit 82f90ac

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

jupyter_client/asynchronous/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class AsyncKernelClient(KernelClient):
3434
raising :exc:`queue.Empty` if no message arrives within ``timeout`` seconds.
3535
"""
3636

37-
context = Instance(zmq.asyncio.Context)
37+
context = Instance(zmq.asyncio.Context) # type:ignore[assignment]
3838

3939
def _context_default(self) -> zmq.asyncio.Context:
4040
self._created_context = True
@@ -52,11 +52,11 @@ def _context_default(self) -> zmq.asyncio.Context:
5252
wait_for_ready = KernelClient._async_wait_for_ready
5353

5454
# The classes to use for the various channels
55-
shell_channel_class = Type(AsyncZMQSocketChannel)
56-
iopub_channel_class = Type(AsyncZMQSocketChannel)
57-
stdin_channel_class = Type(AsyncZMQSocketChannel)
58-
hb_channel_class = Type(HBChannel)
59-
control_channel_class = Type(AsyncZMQSocketChannel)
55+
shell_channel_class = Type(AsyncZMQSocketChannel) # type:ignore[assignment]
56+
iopub_channel_class = Type(AsyncZMQSocketChannel) # type:ignore[assignment]
57+
stdin_channel_class = Type(AsyncZMQSocketChannel) # type:ignore[assignment]
58+
hb_channel_class = Type(HBChannel) # type:ignore[assignment]
59+
control_channel_class = Type(AsyncZMQSocketChannel) # type:ignore[assignment]
6060

6161
_recv_reply = KernelClient._async_recv_reply
6262

jupyter_client/blocking/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ class BlockingKernelClient(KernelClient):
4949
wait_for_ready = run_sync(KernelClient._async_wait_for_ready)
5050

5151
# The classes to use for the various channels
52-
shell_channel_class = Type(ZMQSocketChannel)
53-
iopub_channel_class = Type(ZMQSocketChannel)
54-
stdin_channel_class = Type(ZMQSocketChannel)
55-
hb_channel_class = Type(HBChannel)
56-
control_channel_class = Type(ZMQSocketChannel)
52+
shell_channel_class = Type(ZMQSocketChannel) # type:ignore[assignment]
53+
iopub_channel_class = Type(ZMQSocketChannel) # type:ignore[assignment]
54+
stdin_channel_class = Type(ZMQSocketChannel) # type:ignore[assignment]
55+
hb_channel_class = Type(HBChannel) # type:ignore[assignment]
56+
control_channel_class = Type(ZMQSocketChannel) # type:ignore[assignment]
5757

5858
_recv_reply = run_sync(KernelClient._async_recv_reply)
5959

jupyter_client/provisioning/provisioner_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class KernelProvisionerMeta(ABCMeta, type(LoggingConfigurable)): # type: ignore
1515
pass
1616

1717

18-
class KernelProvisionerBase(ABC, LoggingConfigurable, metaclass=KernelProvisionerMeta):
18+
class KernelProvisionerBase(ABC, LoggingConfigurable, metaclass=KernelProvisionerMeta): # type: ignore[metaclass]
1919
"""
2020
Abstract base class defining methods for KernelProvisioner classes.
2121

jupyter_client/session.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ def send(
759759
content: dict[str, t.Any] | None = None,
760760
parent: dict[str, t.Any] | None = None,
761761
ident: bytes | list[bytes] | None = None,
762-
buffers: list[bytes] | None = None,
762+
buffers: list[bytes | memoryview[bytes]] | None = None,
763763
track: bool = False,
764764
header: dict[str, t.Any] | None = None,
765765
metadata: dict[str, t.Any] | None = None,
@@ -844,14 +844,15 @@ def send(
844844
raise TypeError(emsg) from e
845845
# memoryview.contiguous is new in 3.3,
846846
# just skip the check on Python 2
847+
assert hasattr(view, "contiguous"), "We should only be on python 3.9+ now"
847848
if hasattr(view, "contiguous") and not view.contiguous:
848849
# zmq requires memoryviews to be contiguous
849850
raise ValueError("Buffer %i (%r) is not contiguous" % (idx, buf))
850851

851852
if self.adapt_version:
852853
msg = adapt(msg, self.adapt_version)
853854
to_send = self.serialize(msg, ident)
854-
to_send.extend(buffers)
855+
to_send.extend(buffers) # type: ignore[arg-type]
855856
longest = max([len(s) for s in to_send])
856857
copy = longest < self.copy_threshold
857858

jupyter_client/ssh/tunnel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import warnings
1818
from getpass import getpass, getuser
1919
from multiprocessing import Process
20+
from types import ModuleType
2021
from typing import Any, cast
2122

2223
try:
@@ -34,6 +35,7 @@ class SSHException(Exception): # type:ignore[no-redef] # noqa
3435
else:
3536
from .forward import forward_tunnel
3637

38+
pexpect: ModuleType | None
3739
try:
3840
import pexpect
3941
except ImportError:
@@ -303,6 +305,7 @@ def openssh_tunnel(
303305

304306

305307
def _stop_tunnel(cmd: Any) -> None:
308+
assert pexpect is not None
306309
pexpect.run(cmd)
307310

308311

jupyter_client/threaded.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ def stop_channels(self) -> None:
335335
if self.ioloop_thread and self.ioloop_thread.is_alive():
336336
self.ioloop_thread.stop()
337337

338-
iopub_channel_class = Type(ThreadedZMQSocketChannel)
339-
shell_channel_class = Type(ThreadedZMQSocketChannel)
340-
stdin_channel_class = Type(ThreadedZMQSocketChannel)
341-
hb_channel_class = Type(HBChannel)
342-
control_channel_class = Type(ThreadedZMQSocketChannel)
338+
iopub_channel_class = Type(ThreadedZMQSocketChannel) # type:ignore[assignment]
339+
shell_channel_class = Type(ThreadedZMQSocketChannel) # type:ignore[assignment]
340+
stdin_channel_class = Type(ThreadedZMQSocketChannel) # type:ignore[assignment]
341+
hb_channel_class = Type(HBChannel) # type:ignore[assignment]
342+
control_channel_class = Type(ThreadedZMQSocketChannel) # type:ignore[assignment]
343343

344344
def is_alive(self) -> bool:
345345
"""Is the kernel process still running?"""

0 commit comments

Comments
 (0)