2525from IPython .core .error import UsageError
2626from IPython .core .interactiveshell import InteractiveShell , InteractiveShellABC
2727from 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]
2929from IPython .core .usage import default_banner
30- from IPython .display import Javascript , display
30+ from IPython .display import Javascript , display # type:ignore[attr-defined]
3131from 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]
3333from jupyter_client .session import Session , extract_header
3434from jupyter_core .paths import jupyter_runtime_dir
3535from 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
0 commit comments