From 145154434b0e38e5e66441dc381070814c64756c 2024-10-21 06:37:40 From: M Bussonnier Date: 2024-10-21 06:37:40 Subject: [PATCH] more types (#14549) --- diff --git a/IPython/core/page.py b/IPython/core/page.py index 31b314e..2eb6c39 100644 --- a/IPython/core/page.py +++ b/IPython/core/page.py @@ -125,7 +125,7 @@ def _detect_screen_size(screen_lines_def): # print('***Screen size:',screen_lines_real,'lines x', # screen_cols,'columns.') # dbg -def pager_page(strng, start=0, screen_lines=0, pager_cmd=None): +def pager_page(strng, start=0, screen_lines=0, pager_cmd=None) -> None: """Display a string, piping through a pager after a certain length. strng can be a mime-bundle dict, supplying multiple representations, @@ -239,7 +239,7 @@ def pager_page(strng, start=0, screen_lines=0, pager_cmd=None): page_dumb(strng,screen_lines=screen_lines) -def page(data, start=0, screen_lines=0, pager_cmd=None): +def page(data, start: int = 0, screen_lines: int = 0, pager_cmd=None): """Display content in a pager, piping through a pager after a certain length. data can be a mime-bundle dict, supplying multiple representations, diff --git a/IPython/utils/frame.py b/IPython/utils/frame.py index 808906b..3d0c1b7 100644 --- a/IPython/utils/frame.py +++ b/IPython/utils/frame.py @@ -15,6 +15,7 @@ Utilities for working with stack frames. #----------------------------------------------------------------------------- import sys +from typing import Any #----------------------------------------------------------------------------- # Code @@ -51,7 +52,7 @@ def extract_vars(*names,**kw): return dict((k,callerNS[k]) for k in names) -def extract_vars_above(*names): +def extract_vars_above(*names: list[str]): """Extract a set of variables by name from another frame. Similar to extractVars(), but with a specified depth of 1, so that names @@ -65,7 +66,7 @@ def extract_vars_above(*names): return dict((k,callerNS[k]) for k in names) -def debugx(expr,pre_msg=''): +def debugx(expr: str, pre_msg: str = ""): """Print the value of an expression from the caller's frame. Takes an expression, evaluates it in the caller's frame and prints both @@ -84,7 +85,8 @@ def debugx(expr,pre_msg=''): # deactivate it by uncommenting the following line, which makes it a no-op #def debugx(expr,pre_msg=''): pass -def extract_module_locals(depth=0): + +def extract_module_locals(depth: int = 0) -> tuple[Any, Any]: """Returns (module, locals) of the function `depth` frames away from the caller""" f = sys._getframe(depth + 1) global_ns = f.f_globals