Skip to content

Commit 762bb26

Browse files
committed
Update typing for traitlets 5.11
1 parent 11d7a33 commit 762bb26

File tree

8 files changed

+37
-35
lines changed

8 files changed

+37
-35
lines changed

ipykernel/embed.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ def embed_kernel(module=None, local_ns=None, **kwargs):
5353

5454
app.kernel.user_module = module
5555
app.kernel.user_ns = local_ns
56-
app.shell.set_completer_frame()
56+
app.shell.set_completer_frame() # type:ignore[union-attr]
5757
app.start()

ipykernel/inprocess/blocking.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ class BlockingInProcessKernelClient(InProcessKernelClient):
7676
"""A blocking in-process kernel client."""
7777

7878
# The classes to use for the various channels.
79-
shell_channel_class = Type(BlockingInProcessChannel)
80-
iopub_channel_class = Type(BlockingInProcessChannel)
81-
stdin_channel_class = Type(BlockingInProcessStdInChannel)
79+
shell_channel_class = Type(BlockingInProcessChannel) # type:ignore[arg-type]
80+
iopub_channel_class = Type(BlockingInProcessChannel) # type:ignore[arg-type]
81+
stdin_channel_class = Type(BlockingInProcessStdInChannel) # type:ignore[arg-type]
8282

8383
def wait_for_ready(self):
8484
"""Wait for kernel info reply on shell channel."""

ipykernel/inprocess/client.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ class InProcessKernelClient(KernelClient):
3939
"""
4040

4141
# The classes to use for the various channels.
42-
shell_channel_class = Type(InProcessChannel)
43-
iopub_channel_class = Type(InProcessChannel)
44-
stdin_channel_class = Type(InProcessChannel)
45-
control_channel_class = Type(InProcessChannel)
46-
hb_channel_class = Type(InProcessHBChannel)
42+
shell_channel_class = Type(InProcessChannel) # type:ignore[arg-type]
43+
iopub_channel_class = Type(InProcessChannel) # type:ignore[arg-type]
44+
stdin_channel_class = Type(InProcessChannel) # type:ignore[arg-type]
45+
control_channel_class = Type(InProcessChannel) # type:ignore[arg-type]
46+
hb_channel_class = Type(InProcessHBChannel) # type:ignore[arg-type]
4747

4848
kernel = Instance("ipykernel.inprocess.ipkernel.InProcessKernel", allow_none=True)
4949

@@ -72,31 +72,33 @@ def start_channels(self, *args, **kwargs):
7272
@property
7373
def shell_channel(self):
7474
if self._shell_channel is None:
75-
self._shell_channel = self.shell_channel_class(self) # type:ignore[operator]
75+
self._shell_channel = self.shell_channel_class(self) # type:ignore[abstract,call-arg]
7676
return self._shell_channel
7777

7878
@property
7979
def iopub_channel(self):
8080
if self._iopub_channel is None:
81-
self._iopub_channel = self.iopub_channel_class(self) # type:ignore[operator]
81+
self._iopub_channel = self.iopub_channel_class(self) # type:ignore[abstract,call-arg]
8282
return self._iopub_channel
8383

8484
@property
8585
def stdin_channel(self):
8686
if self._stdin_channel is None:
87-
self._stdin_channel = self.stdin_channel_class(self) # type:ignore[operator]
87+
self._stdin_channel = self.stdin_channel_class(self) # type:ignore[abstract,call-arg]
8888
return self._stdin_channel
8989

9090
@property
9191
def control_channel(self):
9292
if self._control_channel is None:
93-
self._control_channel = self.control_channel_class(self) # type:ignore[operator]
93+
self._control_channel = self.control_channel_class(
94+
self
95+
) # type:ignore[abstract,call-arg]
9496
return self._control_channel
9597

9698
@property
9799
def hb_channel(self):
98100
if self._hb_channel is None:
99-
self._hb_channel = self.hb_channel_class(self) # type:ignore[operator]
101+
self._hb_channel = self.hb_channel_class(self) # type:ignore[abstract,call-arg]
100102
return self._hb_channel
101103

102104
# Methods for sending specific messages

ipykernel/inprocess/ipkernel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class InProcessKernel(IPythonKernel):
4747
# Kernel interface
4848
# -------------------------------------------------------------------------
4949

50-
shell_class = Type(allow_none=True)
50+
shell_class = Type(allow_none=True) # type:ignore[assignment]
5151
_underlying_iopub_socket = Instance(DummySocket, ())
5252
iopub_thread: IOPubThread = Instance(IOPubThread) # type:ignore[assignment]
5353

ipykernel/ipkernel.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -118,29 +118,29 @@ def __init__(self, **kwargs):
118118
)
119119

120120
# Initialize the InteractiveShell subclass
121-
self.shell = self.shell_class.instance( # type:ignore[attr-defined]
121+
self.shell = self.shell_class.instance(
122122
parent=self,
123123
profile_dir=self.profile_dir,
124124
user_module=self.user_module,
125125
user_ns=self.user_ns,
126126
kernel=self,
127127
compiler_class=XCachingCompiler,
128128
)
129-
self.shell.displayhook.session = self.session
129+
self.shell.displayhook.session = self.session # type:ignore[attr-defined]
130130

131131
jupyter_session_name = os.environ.get('JPY_SESSION_NAME')
132132
if jupyter_session_name:
133133
self.shell.user_ns['__session__'] = jupyter_session_name
134134

135-
self.shell.displayhook.pub_socket = self.iopub_socket
136-
self.shell.displayhook.topic = self._topic("execute_result")
137-
self.shell.display_pub.session = self.session
138-
self.shell.display_pub.pub_socket = self.iopub_socket
135+
self.shell.displayhook.pub_socket = self.iopub_socket # type:ignore[attr-defined]
136+
self.shell.displayhook.topic = self._topic("execute_result") # type:ignore[attr-defined]
137+
self.shell.display_pub.session = self.session # type:ignore[attr-defined]
138+
self.shell.display_pub.pub_socket = self.iopub_socket # type:ignore[attr-defined]
139139

140140
self.comm_manager = comm.get_comm_manager()
141141

142142
assert isinstance(self.comm_manager, HasTraits)
143-
self.shell.configurables.append(self.comm_manager)
143+
self.shell.configurables.append(self.comm_manager) # type:ignore[arg-type]
144144
comm_msg_types = ["comm_open", "comm_msg", "comm_close"]
145145
for msg_type in comm_msg_types:
146146
self.shell_handlers[msg_type] = getattr(self.comm_manager, msg_type)

ipykernel/kernelapp.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@
8989
)
9090

9191
# inherit flags&aliases for any IPython shell apps
92-
kernel_aliases.update(shell_aliases) # type:ignore[arg-type]
92+
kernel_aliases.update(shell_aliases)
9393
kernel_flags.update(shell_flags)
9494

9595
# inherit flags&aliases for Sessions
96-
kernel_aliases.update(session_aliases) # type:ignore[arg-type]
97-
kernel_flags.update(session_flags) # type:ignore[arg-type]
96+
kernel_aliases.update(session_aliases)
97+
kernel_flags.update(session_flags)
9898

9999
_ctrl_c_message = """\
100100
NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

ipykernel/zmqshell.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ def data_pub(self):
525525
)
526526

527527
self._data_pub = self.data_pub_class(parent=self) # type:ignore[has-type]
528-
self._data_pub.session = self.display_pub.session
529-
self._data_pub.pub_socket = self.display_pub.pub_socket
528+
self._data_pub.session = self.display_pub.session # type:ignore[attr-defined]
529+
self._data_pub.pub_socket = self.display_pub.pub_socket # type:ignore[attr-defined]
530530
return self._data_pub
531531

532532
@data_pub.setter
@@ -562,14 +562,14 @@ def _showtraceback(self, etype, evalue, stb):
562562
# Send exception info over pub socket for other clients than the caller
563563
# to pick up
564564
topic = None
565-
if dh.topic:
566-
topic = dh.topic.replace(b"execute_result", b"error")
565+
if dh.topic: # type:ignore[attr-defined]
566+
topic = dh.topic.replace(b"execute_result", b"error") # type:ignore[attr-defined]
567567

568-
dh.session.send(
569-
dh.pub_socket,
568+
dh.session.send( # type:ignore[attr-defined]
569+
dh.pub_socket, # type:ignore[attr-defined]
570570
"error",
571571
json_clean(exc_content),
572-
dh.parent_header,
572+
dh.parent_header, # type:ignore[attr-defined]
573573
ident=topic,
574574
)
575575

@@ -590,8 +590,8 @@ def set_next_input(self, text, replace=False):
590590
def set_parent(self, parent):
591591
"""Set the parent header for associating output with its triggering input"""
592592
self.parent_header = parent
593-
self.displayhook.set_parent(parent)
594-
self.display_pub.set_parent(parent)
593+
self.displayhook.set_parent(parent) # type:ignore[attr-defined]
594+
self.display_pub.set_parent(parent) # type:ignore[attr-defined]
595595
if hasattr(self, "_data_pub"):
596596
self.data_pub.set_parent(parent)
597597
try:

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ matrix.qt.features = [
112112

113113
[tool.hatch.envs.typing]
114114
features = ["test"]
115-
dependencies = ["mypy>=1.5.1", "traitlets>=5.10.1"]
115+
dependencies = ["mypy>=1.5.1", "traitlets>=5.11.2", "ipython>=8.16.1"]
116116
[tool.hatch.envs.typing.scripts]
117117
test = "mypy --install-types --non-interactive {args}"
118118

0 commit comments

Comments
 (0)