##// END OF EJS Templates
more types
M Bussonnier -
Show More
@@ -125,7 +125,7 b' def _detect_screen_size(screen_lines_def):'
125 125 # print('***Screen size:',screen_lines_real,'lines x',
126 126 # screen_cols,'columns.') # dbg
127 127
128 def pager_page(strng, start=0, screen_lines=0, pager_cmd=None):
128 def pager_page(strng, start=0, screen_lines=0, pager_cmd=None) -> None:
129 129 """Display a string, piping through a pager after a certain length.
130 130
131 131 strng can be a mime-bundle dict, supplying multiple representations,
@@ -239,7 +239,7 b' def pager_page(strng, start=0, screen_lines=0, pager_cmd=None):'
239 239 page_dumb(strng,screen_lines=screen_lines)
240 240
241 241
242 def page(data, start=0, screen_lines=0, pager_cmd=None):
242 def page(data, start: int = 0, screen_lines: int = 0, pager_cmd=None):
243 243 """Display content in a pager, piping through a pager after a certain length.
244 244
245 245 data can be a mime-bundle dict, supplying multiple representations,
@@ -15,6 +15,7 b' Utilities for working with stack frames.'
15 15 #-----------------------------------------------------------------------------
16 16
17 17 import sys
18 from typing import Any
18 19
19 20 #-----------------------------------------------------------------------------
20 21 # Code
@@ -51,7 +52,7 b' def extract_vars(*names,**kw):'
51 52 return dict((k,callerNS[k]) for k in names)
52 53
53 54
54 def extract_vars_above(*names):
55 def extract_vars_above(*names: list[str]):
55 56 """Extract a set of variables by name from another frame.
56 57
57 58 Similar to extractVars(), but with a specified depth of 1, so that names
@@ -65,7 +66,7 b' def extract_vars_above(*names):'
65 66 return dict((k,callerNS[k]) for k in names)
66 67
67 68
68 def debugx(expr,pre_msg=''):
69 def debugx(expr: str, pre_msg: str = ""):
69 70 """Print the value of an expression from the caller's frame.
70 71
71 72 Takes an expression, evaluates it in the caller's frame and prints both
@@ -84,7 +85,8 b" def debugx(expr,pre_msg=''):"
84 85 # deactivate it by uncommenting the following line, which makes it a no-op
85 86 #def debugx(expr,pre_msg=''): pass
86 87
87 def extract_module_locals(depth=0):
88
89 def extract_module_locals(depth: int = 0) -> tuple[Any, Any]:
88 90 """Returns (module, locals) of the function `depth` frames away from the caller"""
89 91 f = sys._getframe(depth + 1)
90 92 global_ns = f.f_globals
General Comments 0
You need to be logged in to leave comments. Login now