Skip to content

Commit 17c2f83

Browse files
committed
Some linting fixes
1 parent 4bd16e0 commit 17c2f83

15 files changed

Lines changed: 41 additions & 23 deletions

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
here = Path(__file__).parent.resolve()
7777
version_py = Path(here) / os.pardir / "ipykernel" / "_version.py"
7878
with open(version_py) as f:
79-
exec(compile(f.read(), version_py, "exec"), version_ns)
79+
exec(compile(f.read(), version_py, "exec"), version_ns) # noqa: S102
8080

8181
# The short X.Y version.
8282
version = "%i.%i" % version_ns["version_info"][:2]

ipykernel/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _convert_to_long_pathname(filename):
6666

6767
# test that it works so if there are any issues we fail just once here
6868
_convert_to_long_pathname(__file__)
69-
except Exception:
69+
except Exception: # noqa: S110
7070
pass
7171
else:
7272
convert_to_long_pathname = _convert_to_long_pathname

ipykernel/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def connect_qtconsole(
116116

117117
cf = _find_connection_file(connection_file)
118118

119-
cmd = ";".join(["from qtconsole import qtconsoleapp", "qtconsoleapp.main()"])
119+
cmd = "from qtconsole import qtconsoleapp; qtconsoleapp.main()"
120120

121121
kwargs: dict[str, Any] = {}
122122
# Launch the Qt console in a separate session & process group, so

ipykernel/debugger.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
if e.__class__.__name__ == "DebuggerInitializationError":
4040
_is_debugpy_available = False
4141
else:
42-
raise e
42+
raise
4343

4444
if t.TYPE_CHECKING:
4545
from IPython.core.interactiveshell import InteractiveShell
@@ -470,7 +470,7 @@ async def dumpCell(self, message):
470470
code = message["arguments"]["code"]
471471
file_name = get_file_name(code)
472472

473-
with open(file_name, "w", encoding="utf-8") as f:
473+
with open(file_name, "w", encoding="utf-8") as f: # noqa: ASYNC230
474474
f.write(code)
475475

476476
return {
@@ -500,7 +500,7 @@ async def source(self, message):
500500
reply = {"type": "response", "request_seq": message["seq"], "command": message["command"]}
501501
source_path = message["arguments"]["source"]["path"]
502502
if Path(source_path).is_file():
503-
with open(source_path, encoding="utf-8") as f:
503+
with open(source_path, encoding="utf-8") as f: # noqa: ASYNC230
504504
reply["success"] = True
505505
reply["body"] = {"content": f.read()}
506506
else:

ipykernel/eventloops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def wake(self):
207207
try:
208208
if self.shell_stream.flush(limit=1):
209209
self.kernel.app.ExitMainLoop()
210-
except Exception:
210+
except Exception: # noqa: S110
211211
pass
212212

213213
def on_timer(self, event):
@@ -409,7 +409,7 @@ def handle_int(etype, value, tb):
409409
if shell_stream.flush(limit=1):
410410
# events to process, return control to kernel
411411
return
412-
except BaseException:
412+
except BaseException: # noqa: TRY203
413413
raise
414414
except KeyboardInterrupt:
415415
# Ctrl-C shouldn't crash the kernel

ipykernel/inprocess/ipkernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _input_request(self, prompt, ident, parent, password=False):
107107
frontend.stdin_channel.call_handlers(msg)
108108
break
109109
else:
110-
logging.error("No frontend found for raw_input request")
110+
logging.error("No frontend found for raw_input request") # noqa: LOG015
111111
return ""
112112

113113
# Await a response.

ipykernel/iostream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def stop(self):
318318
# close *all* event pipes, created in any thread
319319
# event pipes can only be used from other threads while self.thread.is_alive()
320320
# so after thread.join, this should be safe
321-
for _thread, event_pipe in self._event_pipes.items():
321+
for event_pipe in self._event_pipes.values():
322322
event_pipe.close()
323323

324324
def close(self):

ipykernel/ipkernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ def do_apply(self, content, bufs, msg_id, reply_metadata):
691691
working.update(ns)
692692
code = f"{resultname} = {fname}(*{argname},**{kwargname})"
693693
try:
694-
exec(code, shell.user_global_ns, shell.user_ns)
694+
exec(code, shell.user_global_ns, shell.user_ns) # noqa: S102
695695
result = working.get(resultname)
696696
finally:
697697
for key in ns:

ipykernel/jsonutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
# holy crap, strptime is not threadsafe.
2828
# Calling it once at import seems to help.
29-
datetime.strptime("2000-01-01", "%Y-%m-%d")
29+
datetime.strptime("2000-01-01", "%Y-%m-%d") # noqa: DTZ007
3030

3131
# -----------------------------------------------------------------------------
3232
# Classes and functions

ipykernel/kernelapp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ def patch_io(self):
588588
def enable(file=sys.__stderr__, all_threads=True, **kwargs):
589589
return faulthandler_enable(file=file, all_threads=all_threads, **kwargs)
590590

591-
faulthandler.enable = enable
591+
faulthandler.enable = enable # type:ignore[assignment]
592592

593593
if hasattr(faulthandler, "register"):
594594
faulthandler_register = faulthandler.register
@@ -698,15 +698,15 @@ def init_pdb(self):
698698
With the non-interruptible version, stopping pdb() locks up the kernel in a
699699
non-recoverable state.
700700
"""
701-
import pdb
701+
import pdb # noqa: T100
702702

703703
from IPython.core import debugger
704704

705705
if hasattr(debugger, "InterruptiblePdb"):
706706
# Only available in newer IPython releases:
707707
debugger.Pdb = debugger.InterruptiblePdb # type:ignore[misc]
708708
pdb.Pdb = debugger.Pdb # type:ignore[assignment,misc]
709-
pdb.set_trace = debugger.set_trace
709+
pdb.set_trace = debugger.set_trace # type:ignore[assignment]
710710

711711
@catch_config_error
712712
def initialize(self, argv=None):

0 commit comments

Comments
 (0)