@@ -71,8 +71,8 @@ def wrap(cls, func):
7171 """
7272 @functools .wraps (func )
7373 def transformer_factory (** kwargs ):
74- return cls (func , ** kwargs )
75-
74+ return cls (func , ** kwargs ) # type: ignore [call-arg]
75+
7676 return transformer_factory
7777
7878class StatelessInputTransformer (InputTransformer ):
@@ -194,7 +194,7 @@ def assemble_logical_lines():
194194 line = '' .join (parts )
195195
196196# Utilities
197- def _make_help_call (target , esc , lspace ) :
197+ def _make_help_call (target : str , esc : str , lspace : str ) -> str :
198198 """Prepares a pinfo(2)/psearch call from a target name and the escape
199199 (i.e. ? or ??)"""
200200 method = 'pinfo2' if esc == '??' \
@@ -212,25 +212,28 @@ def _make_help_call(target, esc, lspace):
212212
213213
214214# These define the transformations for the different escape characters.
215- def _tr_system (line_info ):
215+ def _tr_system (line_info : LineInfo ):
216216 "Translate lines escaped with: !"
217217 cmd = line_info .line .lstrip ().lstrip (ESC_SHELL )
218218 return '%sget_ipython().system(%r)' % (line_info .pre , cmd )
219219
220- def _tr_system2 (line_info ):
220+
221+ def _tr_system2 (line_info : LineInfo ):
221222 "Translate lines escaped with: !!"
222223 cmd = line_info .line .lstrip ()[2 :]
223224 return '%sget_ipython().getoutput(%r)' % (line_info .pre , cmd )
224225
225- def _tr_help (line_info ):
226+
227+ def _tr_help (line_info : LineInfo ):
226228 "Translate lines escaped with: ?/??"
227229 # A naked help line should just fire the intro help screen
228230 if not line_info .line [1 :]:
229231 return 'get_ipython().show_usage()'
230232
231233 return _make_help_call (line_info .ifun , line_info .esc , line_info .pre )
232234
233- def _tr_magic (line_info ):
235+
236+ def _tr_magic (line_info : LineInfo ):
234237 "Translate lines escaped with: %"
235238 tpl = '%sget_ipython().run_line_magic(%r, %r)'
236239 if line_info .line .startswith (ESC_MAGIC2 ):
@@ -241,17 +244,20 @@ def _tr_magic(line_info):
241244 t_magic_name = t_magic_name .lstrip (ESC_MAGIC )
242245 return tpl % (line_info .pre , t_magic_name , t_magic_arg_s )
243246
244- def _tr_quote (line_info ):
247+
248+ def _tr_quote (line_info : LineInfo ):
245249 "Translate lines escaped with: ,"
246250 return '%s%s("%s")' % (line_info .pre , line_info .ifun ,
247251 '", "' .join (line_info .the_rest .split ()) )
248252
249- def _tr_quote2 (line_info ):
253+
254+ def _tr_quote2 (line_info : LineInfo ):
250255 "Translate lines escaped with: ;"
251256 return '%s%s("%s")' % (line_info .pre , line_info .ifun ,
252257 line_info .the_rest )
253258
254- def _tr_paren (line_info ):
259+
260+ def _tr_paren (line_info : LineInfo ):
255261 "Translate lines escaped with: /"
256262 return '%s%s(%s)' % (line_info .pre , line_info .ifun ,
257263 ", " .join (line_info .the_rest .split ()))
@@ -266,9 +272,8 @@ def _tr_paren(line_info):
266272 ESC_PAREN : _tr_paren }
267273
268274@StatelessInputTransformer .wrap
269- def escaped_commands (line ):
270- """Transform escaped commands - %magic, !system, ?help + various autocalls.
271- """
275+ def escaped_commands (line : str ):
276+ """Transform escaped commands - %magic, !system, ?help + various autocalls."""
272277 if not line or line .isspace ():
273278 return line
274279 lineinf = LineInfo (line )
@@ -342,20 +347,22 @@ def ends_in_comment_or_string(src):
342347
343348
344349@StatelessInputTransformer .wrap
345- def help_end (line ):
350+ def help_end (line : str ):
346351 """Translate lines with ?/?? at the end"""
347352 m = _help_end_re .search (line )
348353 if m is None or ends_in_comment_or_string (line ):
349354 return line
350355 target = m .group (1 )
351356 esc = m .group (3 )
352- lspace = _initial_space_re .match (line ).group (0 )
357+ match = _initial_space_re .match (line )
358+ assert match is not None
359+ lspace = match .group (0 )
353360
354361 return _make_help_call (target , esc , lspace )
355362
356363
357364@CoroutineInputTransformer .wrap
358- def cellmagic (end_on_blank_line = False ):
365+ def cellmagic (end_on_blank_line : bool = False ):
359366 """Captures & transforms cell magics.
360367
361368 After a cell magic is started, this stores up any lines it gets until it is
0 commit comments