Skip to content

Commit 817258d

Browse files
authored
Fix types and sync lint deps (#1070)
fix types and sync lint deps
1 parent e3c74d0 commit 817258d

File tree

7 files changed

+25
-21
lines changed

7 files changed

+25
-21
lines changed

ipykernel/inprocess/tests/test_kernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from io import StringIO
77

88
import pytest
9-
from IPython.utils.io import capture_output
9+
from IPython.utils.io import capture_output # type:ignore[attr-defined]
1010
from jupyter_client.session import Session
1111

1212
from ipykernel.inprocess.blocking import BlockingInProcessKernelClient

ipykernel/ipkernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from .zmqshell import ZMQInteractiveShell
2727

2828
try:
29-
from IPython.core.interactiveshell import _asyncio_runner
29+
from IPython.core.interactiveshell import _asyncio_runner # type:ignore[attr-defined]
3030
except ImportError:
3131
_asyncio_runner = None
3232

ipykernel/kernelapp.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from logging import StreamHandler
1616

1717
import zmq
18-
from IPython.core.application import (
18+
from IPython.core.application import ( # type:ignore[attr-defined]
1919
BaseIPythonApplication,
2020
base_aliases,
2121
base_flags,
@@ -88,12 +88,12 @@
8888
)
8989

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

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

9898
_ctrl_c_message = """\
9999
NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.
@@ -114,8 +114,8 @@ class IPKernelApp(BaseIPythonApplication, InteractiveShellApp, ConnectionFileMix
114114
"""The IPYKernel application class."""
115115

116116
name = "ipython-kernel"
117-
aliases = Dict(kernel_aliases)
118-
flags = Dict(kernel_flags)
117+
aliases = Dict(kernel_aliases) # type:ignore[assignment]
118+
flags = Dict(kernel_flags) # type:ignore[assignment]
119119
classes = [IPythonKernel, ZMQInteractiveShell, ProfileDir, Session]
120120
# the kernel class, as an importstring
121121
kernel_class = Type(
@@ -429,7 +429,7 @@ def log_connection_info(self):
429429
self.log.info(line)
430430
# also raw print to the terminal if no parent_handle (`ipython kernel`)
431431
# unless log-level is CRITICAL (--quiet)
432-
if not self.parent_handle and self.log_level < logging.CRITICAL:
432+
if not self.parent_handle and int(self.log_level) < logging.CRITICAL:
433433
print(_ctrl_c_message, file=sys.__stdout__)
434434
for line in lines:
435435
print(line, file=sys.__stdout__)
@@ -658,9 +658,9 @@ def init_pdb(self):
658658

659659
if hasattr(debugger, "InterruptiblePdb"):
660660
# Only available in newer IPython releases:
661-
debugger.Pdb = debugger.InterruptiblePdb
662-
pdb.Pdb = debugger.Pdb # type:ignore[misc]
663-
pdb.set_trace = debugger.set_trace
661+
debugger.Pdb = debugger.InterruptiblePdb # type:ignore
662+
pdb.Pdb = debugger.Pdb # type:ignore
663+
pdb.set_trace = debugger.set_trace # type:ignore[assignment]
664664

665665
@catch_config_error
666666
def initialize(self, argv=None):
@@ -687,7 +687,7 @@ def initialize(self, argv=None):
687687
except Exception:
688688
# Catch exception when initializing signal fails, eg when running the
689689
# kernel on a separate thread
690-
if self.log_level < logging.CRITICAL:
690+
if int(self.log_level) < logging.CRITICAL:
691691
self.log.error("Unable to initialize signal:", exc_info=True)
692692
self.init_kernel()
693693
# shell init steps

ipykernel/tests/test_kernel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def _print_and_exit(sig, frame):
517517

518518

519519
def _start_children():
520-
ip = IPython.get_ipython()
520+
ip = IPython.get_ipython() # type:ignore[attr-defined]
521521
ns = ip.user_ns
522522

523523
cmd = [sys.executable, "-c", f"from {__name__} import _child; _child()"]

ipykernel/tests/test_zmq_shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def test_zmq_interactive_shell(kernel):
238238

239239
with warnings.catch_warnings():
240240
warnings.simplefilter("ignore", DeprecationWarning)
241-
shell.data_pub_class = MagicMock()
241+
shell.data_pub_class = MagicMock() # type:ignore
242242
shell.data_pub
243243
shell.kernel = kernel
244244
shell.set_next_input("hi")

ipykernel/zmqshell.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
from IPython.core.error import UsageError
2626
from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC
2727
from IPython.core.magic import Magics, line_magic, magics_class
28-
from IPython.core.magics import CodeMagics, MacroToEdit
28+
from IPython.core.magics import CodeMagics, MacroToEdit # type:ignore[attr-defined]
2929
from IPython.core.usage import default_banner
30-
from IPython.display import Javascript, display
30+
from IPython.display import Javascript, display # type:ignore[attr-defined]
3131
from IPython.utils import openpy
32-
from IPython.utils.process import arg_split, system
32+
from IPython.utils.process import arg_split, system # type:ignore[attr-defined]
3333
from jupyter_client.session import Session, extract_header
3434
from jupyter_core.paths import jupyter_runtime_dir
3535
from traitlets import Any, CBool, CBytes, Dict, Instance, Type, default, observe
@@ -296,6 +296,7 @@ def edit(self, parameter_s="", last_call=None):
296296
filename = os.path.abspath(filename)
297297

298298
payload = {"source": "edit_magic", "filename": filename, "line_number": lineno}
299+
assert self.shell is not None
299300
self.shell.payload_manager.write_payload(payload)
300301

301302
# A few magics that are adapted to the specifics of using pexpect and a
@@ -304,6 +305,7 @@ def edit(self, parameter_s="", last_call=None):
304305
@line_magic
305306
def clear(self, arg_s):
306307
"""Clear the terminal."""
308+
assert self.shell is not None
307309
if os.name == "posix":
308310
self.shell.system("clear")
309311
else:
@@ -324,6 +326,7 @@ def less(self, arg_s):
324326
raise UsageError("Missing filename.")
325327

326328
if arg_s.endswith(".py"):
329+
assert self.shell is not None
327330
cont = self.shell.pycolorize(openpy.read_py_file(arg_s, skip_encoding_cookie=False))
328331
else:
329332
with open(arg_s) as fid:
@@ -338,6 +341,7 @@ def less(self, arg_s):
338341
@line_magic
339342
def man(self, arg_s):
340343
"""Find the man page for the given command and display in pager."""
344+
assert self.shell is not None
341345
page.page(self.shell.getoutput("man %s | col -b" % arg_s, split=False))
342346

343347
@line_magic
@@ -430,7 +434,7 @@ class ZMQInteractiveShell(InteractiveShell):
430434

431435
displayhook_class = Type(ZMQShellDisplayHook)
432436
display_pub_class = Type(ZMQDisplayPublisher)
433-
data_pub_class = Any()
437+
data_pub_class = Any() # type:ignore[assignment]
434438
kernel = Any()
435439
parent_header = Any()
436440

@@ -511,7 +515,7 @@ def data_pub(self):
511515
stacklevel=2,
512516
)
513517

514-
self._data_pub = self.data_pub_class(parent=self)
518+
self._data_pub = self.data_pub_class(parent=self) # type:ignore[has-type]
515519
self._data_pub.session = self.display_pub.session
516520
self._data_pub.pub_socket = self.display_pub.pub_socket
517521
return self._data_pub

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ dependencies = ["mypy>=0.990"]
111111
test = "mypy --install-types --non-interactive {args:.}"
112112

113113
[tool.hatch.envs.lint]
114-
dependencies = ["black==22.10.0", "mdformat>0.7", "ruff==0.0.189"]
114+
dependencies = ["black==22.12.0", "mdformat>0.7", "ruff==0.0.207"]
115115
detached = true
116116
[tool.hatch.envs.lint.scripts]
117117
style = [

0 commit comments

Comments
 (0)