Skip to content

Commit 9cd626b

Browse files
committed
ruff-check unsafe-fixes
1 parent 920da73 commit 9cd626b

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

ipykernel/debugger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def start(self):
429429
(self.shell_socket.getsockopt(ROUTING_ID)),
430430
)
431431

432-
ident, msg = self.session.recv(self.shell_socket, mode=0)
432+
_ident, msg = self.session.recv(self.shell_socket, mode=0)
433433
self.debugpy_initialized = msg["content"]["status"] == "ok"
434434

435435
# Don't remove leading empty lines when debugging so the breakpoints are correctly positioned

ipykernel/inprocess/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def _dispatch_to_kernel(self, msg):
206206
else:
207207
loop = asyncio.get_event_loop() # type:ignore[unreachable]
208208
loop.run_until_complete(kernel.dispatch_shell(msg_parts))
209-
idents, reply_msg = self.session.recv(stream, copy=False)
209+
_idents, reply_msg = self.session.recv(stream, copy=False)
210210
self.shell_channel.call_handlers_later(reply_msg)
211211

212212
def get_shell_msg(self, block=True, timeout=None):

ipykernel/inprocess/ipkernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _io_dispatch(self, change):
135135
"""Called when a message is sent to the IO socket."""
136136
assert self.iopub_socket.io_thread is not None
137137
assert self.session is not None
138-
ident, msg = self.session.recv(self.iopub_socket.io_thread.socket, copy=False)
138+
_ident, msg = self.session.recv(self.iopub_socket.io_thread.socket, copy=False)
139139
for frontend in self.frontends:
140140
assert frontend is not None
141141
frontend.iopub_channel.call_handlers(msg)

tests/inprocess/test_kernel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_pylab(kc):
5757
"""Does %pylab work in the in-process kernel?"""
5858
_ = pytest.importorskip("matplotlib", reason="This test requires matplotlib")
5959
kc.execute("%pylab")
60-
out, err = assemble_output(kc.get_iopub_msg)
60+
out, _err = assemble_output(kc.get_iopub_msg)
6161
assert "matplotlib" in out
6262

6363

@@ -85,7 +85,7 @@ def test_stdout(kc):
8585
kc = BlockingInProcessKernelClient(kernel=kernel, session=kernel.session)
8686
kernel.frontends.append(kc)
8787
kc.execute('print("bar")')
88-
out, err = assemble_output(kc.get_iopub_msg)
88+
out, _err = assemble_output(kc.get_iopub_msg)
8989
assert out == "bar\n"
9090

9191

@@ -102,7 +102,7 @@ def test_capfd(kc):
102102
kernel.frontends.append(kc)
103103
kc.execute("import os")
104104
kc.execute('os.system("echo capfd")')
105-
out, err = assemble_output(kc.iopub_channel)
105+
out, _err = assemble_output(kc.iopub_channel)
106106
assert out == "capfd\n"
107107

108108

tests/test_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _setup_env():
2323

2424
def test_async_await():
2525
flush_channels(KC)
26-
msg_id, content = execute("import asyncio; await asyncio.sleep(0.1)", KC)
26+
_msg_id, content = execute("import asyncio; await asyncio.sleep(0.1)", KC)
2727
assert content["status"] == "ok", content
2828

2929

tests/test_embed_kernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def connection_file_ready(connection_file):
6464
time.sleep(0.1)
6565

6666
if kernel.poll() is not None:
67-
o, e = kernel.communicate()
67+
_o, e = kernel.communicate()
6868
raise OSError("Kernel failed to start:\n%s" % e)
6969

7070
if not os.path.exists(connection_file):

tests/test_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def test_echo_watch(ctx):
222222
print(f"{p.stderr}=", file=sys.stderr)
223223
assert p.returncode == 0
224224
while s.poll(timeout=100):
225-
ident, msg = session.recv(s)
225+
_ident, msg = session.recv(s)
226226
assert msg is not None # for type narrowing
227227
if msg["header"]["msg_type"] == "stream" and msg["content"]["name"] == "stdout":
228228
stdout_chunks.append(msg["content"]["text"])

tests/test_kernel.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
def _check_master(kc, expected=True, stream="stdout"):
3535
execute(kc=kc, code="import sys")
3636
flush_channels(kc)
37-
msg_id, content = execute(kc=kc, code="print(sys.%s._is_master_process())" % stream)
38-
stdout, stderr = assemble_output(kc.get_iopub_msg)
37+
_msg_id, _content = execute(kc=kc, code="print(sys.%s._is_master_process())" % stream)
38+
stdout, _stderr = assemble_output(kc.get_iopub_msg)
3939
assert stdout.strip() == repr(expected)
4040

4141

@@ -51,7 +51,7 @@ def _check_status(content):
5151
def test_simple_print():
5252
"""simple print statement in kernel"""
5353
with kernel() as kc:
54-
msg_id, content = execute(kc=kc, code="print('hi')")
54+
_msg_id, _content = execute(kc=kc, code="print('hi')")
5555
stdout, stderr = assemble_output(kc.get_iopub_msg)
5656
assert stdout == "hi\n"
5757
assert stderr == ""
@@ -251,7 +251,7 @@ def test_capture_fd():
251251
"""simple print statement in kernel"""
252252
with kernel() as kc:
253253
iopub = kc.iopub_channel
254-
msg_id, content = execute(kc=kc, code="import os; os.system('echo capsys')")
254+
_msg_id, _content = execute(kc=kc, code="import os; os.system('echo capsys')")
255255
stdout, stderr = assemble_output(iopub)
256256
assert stdout == "capsys\n"
257257
assert stderr == ""
@@ -262,7 +262,7 @@ def test_capture_fd():
262262
def test_subprocess_peek_at_stream_fileno():
263263
with kernel() as kc:
264264
iopub = kc.iopub_channel
265-
msg_id, content = execute(
265+
_msg_id, _content = execute(
266266
kc=kc,
267267
code="import subprocess, sys; subprocess.run(['python', '-c', 'import os; os.system(\"echo CAP1\"); print(\"CAP2\")'], stderr=sys.stderr)",
268268
)
@@ -275,7 +275,7 @@ def test_subprocess_peek_at_stream_fileno():
275275
def test_sys_path():
276276
"""test that sys.path doesn't get messed up by default"""
277277
with kernel() as kc:
278-
msg_id, content = execute(kc=kc, code="import sys; print(repr(sys.path))")
278+
_msg_id, _content = execute(kc=kc, code="import sys; print(repr(sys.path))")
279279
stdout, stderr = assemble_output(kc.get_iopub_msg)
280280
# for error-output on failure
281281
sys.stderr.write(stderr)
@@ -288,7 +288,7 @@ def test_sys_path_profile_dir():
288288
"""test that sys.path doesn't get messed up when `--profile-dir` is specified"""
289289

290290
with new_kernel(["--profile-dir", locate_profile("default")]) as kc:
291-
msg_id, content = execute(kc=kc, code="import sys; print(repr(sys.path))")
291+
_msg_id, _content = execute(kc=kc, code="import sys; print(repr(sys.path))")
292292
stdout, stderr = assemble_output(kc.get_iopub_msg)
293293
# for error-output on failure
294294
sys.stderr.write(stderr)
@@ -323,7 +323,7 @@ def test_subprocess_print():
323323
]
324324
)
325325

326-
msg_id, content = execute(kc=kc, code=code)
326+
_msg_id, _content = execute(kc=kc, code=code)
327327
stdout, stderr = assemble_output(kc.get_iopub_msg)
328328
assert stdout.count("hello") == np, stdout
329329
for n in range(np):
@@ -347,7 +347,7 @@ def test_subprocess_noprint():
347347
]
348348
)
349349

350-
msg_id, content = execute(kc=kc, code=code)
350+
_msg_id, _content = execute(kc=kc, code=code)
351351
stdout, stderr = assemble_output(kc.get_iopub_msg)
352352
assert stdout == ""
353353
assert stderr == ""
@@ -373,7 +373,7 @@ def test_subprocess_error():
373373
]
374374
)
375375

376-
msg_id, content = execute(kc=kc, code=code)
376+
_msg_id, _content = execute(kc=kc, code=code)
377377
stdout, stderr = assemble_output(kc.get_iopub_msg)
378378
assert stdout == ""
379379
assert "ValueError" in stderr
@@ -400,7 +400,7 @@ def test_raw_input():
400400
kc.input(text)
401401
reply = kc.get_shell_msg(timeout=TIMEOUT)
402402
assert reply["content"]["status"] == "ok"
403-
stdout, stderr = assemble_output(kc.get_iopub_msg)
403+
stdout, _stderr = assemble_output(kc.get_iopub_msg)
404404
assert stdout == text + "\n"
405405

406406

@@ -555,7 +555,7 @@ def test_unc_paths():
555555
kc.execute(code="ls")
556556
reply = kc.get_shell_msg(timeout=TIMEOUT)
557557
assert reply["content"]["status"] == "ok"
558-
out, err = assemble_output(kc.get_iopub_msg)
558+
out, _err = assemble_output(kc.get_iopub_msg)
559559
assert "unc.txt" in out
560560

561561
kc.execute(code="cd")
@@ -774,7 +774,7 @@ def test_shutdown_subprocesses():
774774
"""Kernel exits after polite shutdown_request"""
775775
with new_kernel() as kc:
776776
km = kc.parent
777-
msg_id, reply = execute(
777+
_msg_id, reply = execute(
778778
f"from {__name__} import _start_children\n_start_children()",
779779
kc=kc,
780780
user_expressions={

tests/test_message_spec.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def test_non_execute_stop_on_error():
426426
def test_user_expressions():
427427
flush_channels()
428428

429-
msg_id, reply = execute(code="x=1", user_expressions=dict(foo="x+1"))
429+
_msg_id, reply = execute(code="x=1", user_expressions=dict(foo="x+1"))
430430
user_expressions = reply["user_expressions"]
431431
assert user_expressions == {
432432
"foo": {
@@ -440,7 +440,7 @@ def test_user_expressions():
440440
def test_user_expressions_fail():
441441
flush_channels()
442442

443-
msg_id, reply = execute(code="x=0", user_expressions=dict(foo="nosuchname"))
443+
_msg_id, reply = execute(code="x=0", user_expressions=dict(foo="nosuchname"))
444444
user_expressions = reply["user_expressions"]
445445
foo = user_expressions["foo"]
446446
assert foo["status"] == "error"
@@ -572,7 +572,7 @@ def test_single_payload():
572572
transform) should avoid setting multiple set_next_input).
573573
"""
574574
flush_channels()
575-
msg_id, reply = execute(
575+
_msg_id, reply = execute(
576576
code="ip = get_ipython()\nfor i in range(3):\n ip.set_next_input('Hello There')\n"
577577
)
578578
payload = reply["payload"]
@@ -635,7 +635,7 @@ def test_history_search():
635635
def test_stream():
636636
flush_channels()
637637

638-
msg_id, reply = execute("print('hi')")
638+
msg_id, _reply = execute("print('hi')")
639639

640640
stdout = KC.get_iopub_msg(timeout=TIMEOUT)
641641
validate_message(stdout, "stream", msg_id)
@@ -646,7 +646,7 @@ def test_stream():
646646
def test_display_data():
647647
flush_channels()
648648

649-
msg_id, reply = execute("from IPython.display import display; display(1)")
649+
msg_id, _reply = execute("from IPython.display import display; display(1)")
650650

651651
display = KC.get_iopub_msg(timeout=TIMEOUT)
652652
validate_message(display, "display_data", parent=msg_id)

0 commit comments

Comments
 (0)