Skip to content

Commit 4f0e252

Browse files
authored
Update CI (#1073)
update ci
1 parent 817258d commit 4f0e252

File tree

13 files changed

+58
-40
lines changed

13 files changed

+58
-40
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ repos:
3636
- id: black
3737

3838
- repo: https://github.com/charliermarsh/ruff-pre-commit
39-
rev: v0.0.207
39+
rev: v0.0.215
4040
hooks:
4141
- id: ruff
4242
args: ["--fix"]

ipykernel/connect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def get_connection_file(app=None):
2626
from ipykernel.kernelapp import IPKernelApp
2727

2828
if not IPKernelApp.initialized():
29-
raise RuntimeError("app not specified, and not in a running Kernel")
29+
msg = "app not specified, and not in a running Kernel"
30+
raise RuntimeError(msg)
3031

3132
app = IPKernelApp.instance()
3233
return filefind(app.connection_file, [".", app.connection_dir])

ipykernel/eventloops.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,8 @@ def set_qt_api_env_from_gui(gui):
473473
}
474474
if loaded is not None and gui != 'qt':
475475
if qt_env2gui[loaded] != gui:
476-
raise ImportError(
477-
f'Cannot switch Qt versions for this session; must use {qt_env2gui[loaded]}.'
478-
)
476+
msg = f'Cannot switch Qt versions for this session; must use {qt_env2gui[loaded]}.'
477+
raise ImportError(msg)
479478

480479
if qt_api is not None and gui != 'qt':
481480
if qt_env2gui[qt_api] != gui:
@@ -526,9 +525,8 @@ def set_qt_api_env_from_gui(gui):
526525
if 'QT_API' in os.environ.keys():
527526
del os.environ['QT_API']
528527
else:
529-
raise ValueError(
530-
f'Unrecognized Qt version: {gui}. Should be "qt4", "qt5", "qt6", or "qt".'
531-
)
528+
msg = f'Unrecognized Qt version: {gui}. Should be "qt4", "qt5", "qt6", or "qt".'
529+
raise ValueError(msg)
532530

533531
# Do the actual import now that the environment variable is set to make sure it works.
534532
try:
@@ -543,7 +541,8 @@ def set_qt_api_env_from_gui(gui):
543541
def make_qt_app_for_kernel(gui, kernel):
544542
"""Sets the `QT_API` environment variable if it isn't already set."""
545543
if hasattr(kernel, 'app'):
546-
raise RuntimeError('Kernel already running a Qt event loop.')
544+
msg = 'Kernel already running a Qt event loop.'
545+
raise RuntimeError(msg)
547546

548547
set_qt_api_env_from_gui(gui)
549548
# This import is guaranteed to work now:
@@ -566,10 +565,11 @@ def enable_gui(gui, kernel=None):
566565
if Application.initialized():
567566
kernel = getattr(Application.instance(), "kernel", None)
568567
if kernel is None:
569-
raise RuntimeError(
568+
msg = (
570569
"You didn't specify a kernel,"
571570
" and no IPython Application with a kernel appears to be running."
572571
)
572+
raise RuntimeError(msg)
573573
if gui is None:
574574
# User wants to turn off integration; clear any evidence if Qt was the last one.
575575
if hasattr(kernel, 'app'):
@@ -581,7 +581,8 @@ def enable_gui(gui, kernel=None):
581581

582582
loop = loop_map[gui]
583583
if loop and kernel.eventloop is not None and kernel.eventloop is not loop:
584-
raise RuntimeError("Cannot activate multiple GUI eventloops")
584+
msg = "Cannot activate multiple GUI eventloops"
585+
raise RuntimeError(msg)
585586
kernel.eventloop = loop
586587
# We set `eventloop`; the function the user chose is executed in `Kernel.enter_eventloop`, thus
587588
# any exceptions raised during the event loop will not be shown in the client.

ipykernel/inprocess/channels.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def call_handlers(self, msg):
4040
4141
Subclasses should override this method to handle incoming messages.
4242
"""
43-
raise NotImplementedError("call_handlers must be defined in a subclass.")
43+
msg = "call_handlers must be defined in a subclass."
44+
raise NotImplementedError(msg)
4445

4546
def flush(self, timeout=1.0):
4647
"""Flush the channel."""

ipykernel/inprocess/client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ def history(self, raw=True, output=False, hist_access_type="range", **kwds):
154154
def shutdown(self, restart=False):
155155
"""Handle shutdown."""
156156
# FIXME: What to do here?
157-
raise NotImplementedError("Cannot shutdown in-process kernel")
157+
msg = "Cannot shutdown in-process kernel"
158+
raise NotImplementedError(msg)
158159

159160
def kernel_info(self):
160161
"""Request kernel info."""
@@ -175,7 +176,8 @@ def comm_info(self, target_name=None):
175176
def input(self, string):
176177
"""Handle kernel input."""
177178
if self.kernel is None:
178-
raise RuntimeError("Cannot send input reply. No kernel exists.")
179+
msg = "Cannot send input reply. No kernel exists."
180+
raise RuntimeError(msg)
179181
self.kernel.raw_input_str = string
180182

181183
def is_complete(self, code):
@@ -188,7 +190,8 @@ def _dispatch_to_kernel(self, msg):
188190
"""Send a message to the kernel and handle a reply."""
189191
kernel = self.kernel
190192
if kernel is None:
191-
raise RuntimeError("Cannot send request. No kernel exists.")
193+
msg = "Cannot send request. No kernel exists."
194+
raise RuntimeError(msg)
192195

193196
stream = kernel.shell_stream
194197
self.session.send(stream, msg)

ipykernel/inprocess/manager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ def _kill_kernel(self):
6666

6767
def interrupt_kernel(self):
6868
"""Interrupt the kernel."""
69-
raise NotImplementedError("Cannot interrupt in-process kernel.")
69+
msg = "Cannot interrupt in-process kernel."
70+
raise NotImplementedError(msg)
7071

7172
def signal_kernel(self, signum):
7273
"""Send a signal to the kernel."""
73-
raise NotImplementedError("Cannot signal in-process kernel.")
74+
msg = "Cannot signal in-process kernel."
75+
raise NotImplementedError(msg)
7476

7577
def is_alive(self):
7678
"""Test if the kernel is alive."""

ipykernel/iostream.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ def fileno(self):
312312
if getattr(self, "_original_stdstream_copy", None) is not None:
313313
return self._original_stdstream_copy
314314
else:
315-
raise io.UnsupportedOperation("fileno")
315+
msg = "fileno"
316+
raise io.UnsupportedOperation(msg)
316317

317318
def _watch_pipe_fd(self):
318319
"""
@@ -415,7 +416,8 @@ def __init__(
415416
if hasattr(echo, "read") and hasattr(echo, "write"):
416417
self.echo = echo
417418
else:
418-
raise ValueError("echo argument must be a file like object")
419+
msg = "echo argument must be a file like object"
420+
raise ValueError(msg)
419421

420422
def isatty(self):
421423
"""Return a bool indicating whether this is an 'interactive' stream.
@@ -540,7 +542,8 @@ def write(self, string: str) -> Optional[int]: # type:ignore[override]
540542
"""
541543

542544
if not isinstance(string, str):
543-
raise TypeError(f"write() argument must be str, not {type(string)}")
545+
msg = f"write() argument must be str, not {type(string)}"
546+
raise TypeError(msg)
544547

545548
if self.echo is not None:
546549
try:
@@ -550,7 +553,8 @@ def write(self, string: str) -> Optional[int]: # type:ignore[override]
550553
print(f"Write failed: {e}", file=sys.__stderr__)
551554

552555
if self.pub_thread is None:
553-
raise ValueError("I/O operation on closed file")
556+
msg = "I/O operation on closed file"
557+
raise ValueError(msg)
554558
else:
555559

556560
is_child = not self._is_master_process()
@@ -573,7 +577,8 @@ def write(self, string: str) -> Optional[int]: # type:ignore[override]
573577
def writelines(self, sequence):
574578
"""Write lines to the stream."""
575579
if self.pub_thread is None:
576-
raise ValueError("I/O operation on closed file")
580+
msg = "I/O operation on closed file"
581+
raise ValueError(msg)
577582
else:
578583
for string in sequence:
579584
self.write(string)

ipykernel/jsonutil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ def json_clean(obj): # pragma: no cover
146146
nkeys = len(obj)
147147
nkeys_collapsed = len(set(map(str, obj)))
148148
if nkeys != nkeys_collapsed:
149-
raise ValueError(
149+
msg = (
150150
"dict cannot be safely converted to JSON: "
151151
"key collision would lead to dropped values"
152152
)
153+
raise ValueError(msg)
153154
# If all OK, proceed by making the new dict that will be json-safe
154155
out = {}
155156
for k, v in obj.items():

ipykernel/kernelbase.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,9 +1146,8 @@ def _send_abort_reply(self, stream, msg, idents):
11461146
def _no_raw_input(self):
11471147
"""Raise StdinNotImplementedError if active frontend doesn't support
11481148
stdin."""
1149-
raise StdinNotImplementedError(
1150-
"raw_input was called, but this frontend does not support stdin."
1151-
)
1149+
msg = "raw_input was called, but this frontend does not support stdin."
1150+
raise StdinNotImplementedError(msg)
11521151

11531152
def getpass(self, prompt="", stream=None):
11541153
"""Forward getpass to frontends
@@ -1158,9 +1157,8 @@ def getpass(self, prompt="", stream=None):
11581157
StdinNotImplementedError if active frontend doesn't support stdin.
11591158
"""
11601159
if not self._allow_stdin:
1161-
raise StdinNotImplementedError(
1162-
"getpass was called, but this frontend does not support input requests."
1163-
)
1160+
msg = "getpass was called, but this frontend does not support input requests."
1161+
raise StdinNotImplementedError(msg)
11641162
if stream is not None:
11651163
import warnings
11661164

@@ -1184,9 +1182,8 @@ def raw_input(self, prompt=""):
11841182
StdinNotImplementedError if active frontend doesn't support stdin.
11851183
"""
11861184
if not self._allow_stdin:
1187-
raise StdinNotImplementedError(
1188-
"raw_input was called, but this frontend does not support input requests."
1189-
)
1185+
msg = "raw_input was called, but this frontend does not support input requests."
1186+
raise StdinNotImplementedError(msg)
11901187
return self._input_request(
11911188
str(prompt),
11921189
self._parent_ident["shell"],
@@ -1229,7 +1226,8 @@ def _input_request(self, prompt, ident, parent, password=False):
12291226
break
12301227
except KeyboardInterrupt:
12311228
# re-raise KeyboardInterrupt, to truncate traceback
1232-
raise KeyboardInterrupt("Interrupted by user") from None
1229+
msg = "Interrupted by user"
1230+
raise KeyboardInterrupt(msg) from None
12331231
except Exception:
12341232
self.log.warning("Invalid Message:", exc_info=True)
12351233

ipykernel/parentpoller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def __init__(self, interrupt_handle=None, parent_handle=None):
6666
assert interrupt_handle or parent_handle
6767
super().__init__()
6868
if ctypes is None:
69-
raise ImportError("ParentPollerWindows requires ctypes")
69+
msg = "ParentPollerWindows requires ctypes"
70+
raise ImportError(msg)
7071
self.daemon = True
7172
self.interrupt_handle = interrupt_handle
7273
self.parent_handle = parent_handle

0 commit comments

Comments
 (0)