2929
3030from . import decorators as dec
3131from . import skipdoctest
32+ from types import TracebackType
33+ from typing import List , Optional , Tuple , Type
3234
3335
3436# The docstring for full_path doctests differently on win32 (different path
@@ -67,7 +69,7 @@ def full_path(startPath: str, files: list[str]) -> list[str]:
6769 return [ os .path .join (base ,f ) for f in files ]
6870
6971
70- def parse_test_output (txt ) :
72+ def parse_test_output (txt : str ) -> Tuple [ int , int ] :
7173 """Parse the output of a test run and return errors, failures.
7274
7375 Parameters
@@ -113,7 +115,7 @@ def parse_test_output(txt):
113115parse_test_output .__test__ = False
114116
115117
116- def default_argv ():
118+ def default_argv () -> List [ str ] :
117119 """Return a valid default argv for creating testing instances of ipython"""
118120
119121 return [
@@ -126,7 +128,7 @@ def default_argv():
126128 ]
127129
128130
129- def default_config ():
131+ def default_config () -> Config :
130132 """Return a config object with good defaults for testing."""
131133 config = Config ()
132134 config .TerminalInteractiveShell .colors = "nocolor"
@@ -139,7 +141,7 @@ def default_config():
139141 return config
140142
141143
142- def get_ipython_cmd (as_string = False ):
144+ def get_ipython_cmd (as_string : bool = False ) -> List [ str ] :
143145 """
144146 Return appropriate IPython command line name. By default, this will return
145147 a list that can be used with subprocess.Popen, for example, but passing
@@ -157,7 +159,7 @@ def get_ipython_cmd(as_string=False):
157159
158160 return ipython_cmd
159161
160- def ipexec (fname , options = None , commands = ()):
162+ def ipexec (fname : str , options : Optional [ List [ str ]] = None , commands : Tuple [ str , ...] = ()) -> Tuple [ str , str ] :
161163 """Utility to call 'ipython filename'.
162164
163165 Starts IPython with a minimal and safe configuration to make startup as fast
@@ -215,8 +217,8 @@ def ipexec(fname, options=None, commands=()):
215217 return out , err
216218
217219
218- def ipexec_validate (fname , expected_out , expected_err = '' ,
219- options = None , commands = ()):
220+ def ipexec_validate (fname : str , expected_out : str , expected_err : str = '' ,
221+ options : Optional [ List [ str ]] = None , commands : Tuple [ str , ...] = ()):
220222 """Utility to call 'ipython filename' and validate output/error.
221223
222224 This function raises an AssertionError if the validation fails.
@@ -267,7 +269,7 @@ class TempFileMixin(unittest.TestCase):
267269
268270 Meant as a mixin class for test cases."""
269271
270- def mktmp (self , src , ext = '.py' ):
272+ def mktmp (self , src : str , ext : str = '.py' ):
271273 """Make a valid python temp file."""
272274 fname = temp_pyfile (src , ext )
273275 if not hasattr (self , 'tmps' ):
@@ -318,7 +320,7 @@ class AssertPrints:
318320 abcd
319321 def
320322 """
321- def __init__ (self , s , channel = 'stdout' , suppress = True ):
323+ def __init__ (self , s : str , channel : str = 'stdout' , suppress : bool = True ):
322324 self .s = s
323325 if isinstance (self .s , (str , _re_type )):
324326 self .s = [self .s ]
@@ -331,7 +333,7 @@ def __enter__(self):
331333 self .tee = Tee (self .buffer , channel = self .channel )
332334 setattr (sys , self .channel , self .buffer if self .suppress else self .tee )
333335
334- def __exit__ (self , etype , value , traceback ):
336+ def __exit__ (self , etype : Optional [ Type [ BaseException ]] , value : Optional [ BaseException ] , traceback : Optional [ TracebackType ] ):
335337 __tracebackhide__ = True
336338
337339 try :
0 commit comments