Skip to content

Commit a3f58e0

Browse files
committed
update types to fix tests, and propagate errors
1 parent 79ef12d commit a3f58e0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: ipykernel/kernelapp.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from io import FileIO, TextIOWrapper
1717
from logging import StreamHandler
1818
from pathlib import Path
19+
from typing import Optional
1920

2021
import zmq
2122
import zmq.asyncio
@@ -144,9 +145,9 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp, ConnectionFileMix
144145
stdin_socket = Any()
145146
iopub_socket = Any()
146147

147-
iopub_thread: BaseThread
148-
control_thread: BaseThread
149-
shell_channel_thread: BaseThread
148+
iopub_thread: Optional[IOPubThread] = Instance(IOPubThread, allow_none=True) # type:ignore[assignment]
149+
control_thread: Optional[BaseThread] = Instance(BaseThread, allow_none=True) # type:ignore[assignment]
150+
shell_channel_thread: Optional[BaseThread] = Instance(BaseThread, allow_none=True) # type:ignore[assignment]
150151

151152
_ports = Dict()
152153

@@ -263,7 +264,7 @@ def _bind_socket(self, s, port):
263264
raise
264265
return None
265266

266-
def write_connection_file(self):
267+
def write_connection_file(self, **kwargs: t.Any) -> None:
267268
"""write connection info to JSON file"""
268269
cf = self.abs_connection_file
269270
connection_info = dict(
@@ -403,15 +404,15 @@ def close(self):
403404
if self.heartbeat:
404405
self.log.debug("Closing heartbeat channel")
405406
self.heartbeat.context.term()
406-
if self.iopub_thread:
407+
if self.iopub_thread is not None:
407408
self.log.debug("Closing iopub channel")
408409
self.iopub_thread.stop()
409410
self.iopub_thread.close()
410-
if self.control_thread and self.control_thread.is_alive():
411+
if self.control_thread is not None and self.control_thread.is_alive():
411412
self.log.debug("Closing control thread")
412413
self.control_thread.stop()
413414
self.control_thread.join()
414-
if self.shell_channel_thread and self.shell_channel_thread.is_alive():
415+
if self.shell_channel_thread is not None and self.shell_channel_thread.is_alive():
415416
self.log.debug("Closing shell channel thread")
416417
self.shell_channel_thread.stop()
417418
self.shell_channel_thread.join()

0 commit comments

Comments
 (0)