Add missing stubs to pdb and fix related issues in cmd and bdb (#3600)

This commit is contained in:
Jan Verbeek
2020-01-18 16:39:35 +01:00
committed by Jelle Zijlstra
parent b6b9df3836
commit 475d1f75fe
3 changed files with 218 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
from typing import Set, Dict, Iterable, Any, Callable, Tuple, Type, SupportsInt, List, Union, TypeVar, Optional, IO
from typing import Set, Dict, Iterable, Any, Callable, Mapping, Tuple, Type, SupportsInt, List, Union, TypeVar, Optional, IO
from types import FrameType, TracebackType, CodeType
@@ -34,7 +34,7 @@ class Bdb:
def is_skipped_module(self, module_name: str) -> bool: ...
def stop_here(self, frame: FrameType) -> bool: ...
def break_here(self, frame: FrameType) -> bool: ...
def do_clear(self, arg: Any) -> None: ...
def do_clear(self, arg: Any) -> Optional[bool]: ...
def break_anywhere(self, frame: FrameType) -> bool: ...
def user_call(self, frame: FrameType, argument_list: None) -> None: ...
def user_line(self, frame: FrameType) -> None: ...
@@ -57,12 +57,14 @@ class Bdb:
def get_breaks(self, filename: str, lineno: int) -> List[Breakpoint]: ...
def get_file_breaks(self, filename: str) -> List[Breakpoint]: ...
def get_all_breaks(self) -> List[Breakpoint]: ...
def get_stack(self, f: FrameType, t: TracebackType) -> Tuple[List[Tuple[FrameType, int]], int]: ...
def get_stack(self, f: Optional[FrameType], t: Optional[TracebackType]) -> Tuple[List[Tuple[FrameType, int]], int]: ...
def format_stack_entry(self, frame_lineno: int, lprefix: str = ...) -> str: ...
def run(self, cmd: Union[str, CodeType], globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> None: ...
def runeval(self, expr: str, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> None: ...
def runctx(self, cmd: Union[str, CodeType], globals: Dict[str, Any], locals: Dict[str, Any]) -> None: ...
def runcall(self, func: Callable[[Any], _T], *args: Any, **kwds: Any) -> Optional[_T]: ...
def run(
self, cmd: Union[str, CodeType], globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...
) -> None: ...
def runeval(self, expr: str, globals: Optional[Dict[str, Any]] = ..., locals: Optional[Mapping[str, Any]] = ...) -> None: ...
def runctx(self, cmd: Union[str, CodeType], globals: Optional[Dict[str, Any]], locals: Optional[Mapping[str, Any]]) -> None: ...
def runcall(self, func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ...
class Breakpoint:

View File

@@ -36,6 +36,6 @@ class Cmd:
def get_names(self) -> List[str]: ...
# Only the first element of args matters.
def complete_help(self, *args: Any) -> List[str]: ...
def do_help(self, arg: Optional[str]) -> None: ...
def do_help(self, arg: str) -> Optional[bool]: ...
def print_topics(self, header: str, cmds: Optional[List[str]], cmdlen: Any, maxcol: int) -> None: ...
def columnize(self, list: Optional[List[str]], displaywidth: int = ...) -> None: ...

View File

@@ -1,30 +1,52 @@
# NOTE: This stub is incomplete - only contains some global functions
from bdb import Bdb
from cmd import Cmd
from inspect import _SourceObjectType
import signal
import sys
from types import FrameType
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar
from types import CodeType, FrameType, TracebackType
from typing import Any, Callable, ClassVar, Dict, IO, Iterable, List, Mapping, Optional, Sequence, Tuple, TypeVar, Union
_T = TypeVar('_T')
line_prefix: str # undocumented
class Restart(Exception): ...
def run(statement: str, globals: Optional[Dict[str, Any]] = ...,
locals: Optional[Dict[str, Any]] = ...) -> None: ...
locals: Optional[Mapping[str, Any]] = ...) -> None: ...
def runeval(expression: str, globals: Optional[Dict[str, Any]] = ...,
locals: Optional[Dict[str, Any]] = ...) -> Any: ...
def runctx(statement: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> None: ...
def runcall(*args: Any, **kwds: Any) -> Any: ...
locals: Optional[Mapping[str, Any]] = ...) -> Any: ...
def runctx(statement: str, globals: Dict[str, Any], locals: Mapping[str, Any]) -> None: ...
def runcall(func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ...
if sys.version_info >= (3, 7):
def set_trace(*, header: Optional[str] = ...) -> None: ...
else:
def set_trace() -> None: ...
def post_mortem(t: Optional[Any] = ...) -> None: ...
def post_mortem(t: Optional[TracebackType] = ...) -> None: ...
def pm() -> None: ...
class Pdb(Cmd):
class Pdb(Bdb, Cmd):
# Everything here is undocumented, except for __init__
commands_resuming: ClassVar[List[str]]
aliases: Dict[str, str]
mainpyfile: str
_wait_for_mainpyfile: bool
rcLines: List[str]
commands: Dict[int, List[str]]
commands_doprompt: Dict[int, bool]
commands_silent: Dict[int, bool]
commands_defining: bool
commands_bnum: Optional[int]
lineno: Optional[int]
stack: List[Tuple[FrameType, int]]
curindex: int
curframe: Optional[FrameType]
curframe_locals: Mapping[str, Any]
if sys.version_info >= (3, 6):
def __init__(
self,
@@ -52,11 +74,179 @@ class Pdb(Cmd):
stdout: Optional[IO[str]] = ...,
skip: Optional[Iterable[str]] = ...,
) -> None: ...
# TODO: The run* and set_trace() methods are actually defined on bdb.Bdb, from which Pdb inherits.
# Move these methods there once we have a bdb stub.
def run(self, statement: str, globals: Optional[Dict[str, Any]] = ...,
locals: Optional[Dict[str, Any]] = ...) -> None: ...
def runeval(self, expression: str, globals: Optional[Dict[str, Any]] = ...,
locals: Optional[Dict[str, Any]] = ...) -> Any: ...
def runcall(self, func: Callable[..., _T], *args: Any, **kwds: Any) -> Optional[_T]: ...
def set_trace(self, frame: Optional[FrameType] = ...) -> None: ...
def forget(self) -> None: ...
def setup(self, f: Optional[FrameType], t: Optional[TracebackType]) -> None: ...
def execRcLines(self) -> None: ...
def bp_commands(self, frame: FrameType) -> bool: ...
def interaction(self, frame: Optional[FrameType], traceback: Optional[TracebackType]) -> None: ...
def displayhook(self, obj: object) -> None: ...
def handle_command_def(self, line: str) -> bool: ...
def defaultFile(self) -> str: ...
def lineinfo(self, identifier: str) -> Union[Tuple[None, None, None], Tuple[str, str, int]]: ...
def checkline(self, filename: str, lineno: int) -> int: ...
def _getval(self, arg: str) -> object: ...
def print_stack_trace(self) -> None: ...
def print_stack_entry(self, frame_lineno: Tuple[FrameType, int], prompt_prefix: str = ...) -> None: ...
def lookupmodule(self, filename: str) -> Optional[str]: ...
def _runscript(self, filename: str) -> None: ...
def do_commands(self, arg: str) -> Optional[bool]: ...
def do_break(self, arg: str, temporary: bool = ...) -> Optional[bool]: ...
def do_tbreak(self, arg: str) -> Optional[bool]: ...
def do_enable(self, arg: str) -> Optional[bool]: ...
def do_disable(self, arg: str) -> Optional[bool]: ...
def do_condition(self, arg: str) -> Optional[bool]: ...
def do_ignore(self, arg: str) -> Optional[bool]: ...
def do_clear(self, arg: str) -> Optional[bool]: ...
def do_where(self, arg: str) -> Optional[bool]: ...
def do_up(self, arg: str) -> Optional[bool]: ...
def do_down(self, arg: str) -> Optional[bool]: ...
def do_until(self, arg: str) -> Optional[bool]: ...
def do_step(self, arg: str) -> Optional[bool]: ...
def do_next(self, arg: str) -> Optional[bool]: ...
def do_run(self, arg: str) -> Optional[bool]: ...
def do_return(self, arg: str) -> Optional[bool]: ...
def do_continue(self, arg: str) -> Optional[bool]: ...
def do_jump(self, arg: str) -> Optional[bool]: ...
def do_debug(self, arg: str) -> Optional[bool]: ...
def do_quit(self, arg: str) -> Optional[bool]: ...
def do_EOF(self, arg: str) -> Optional[bool]: ...
def do_args(self, arg: str) -> Optional[bool]: ...
def do_retval(self, arg: str) -> Optional[bool]: ...
def do_p(self, arg: str) -> Optional[bool]: ...
def do_pp(self, arg: str) -> Optional[bool]: ...
def do_list(self, arg: str) -> Optional[bool]: ...
def do_whatis(self, arg: str) -> Optional[bool]: ...
def do_alias(self, arg: str) -> Optional[bool]: ...
def do_unalias(self, arg: str) -> Optional[bool]: ...
def do_help(self, arg: str) -> Optional[bool]: ...
do_b = do_break
do_cl = do_clear
do_w = do_where
do_bt = do_where
do_u = do_up
do_d = do_down
do_unt = do_until
do_s = do_step
do_n = do_next
do_restart = do_run
do_r = do_return
do_c = do_continue
do_cont = do_continue
do_j = do_jump
do_q = do_quit
do_exit = do_quit
do_a = do_args
do_rv = do_retval
do_l = do_list
do_h = do_help
def help_exec(self) -> None: ...
def help_pdb(self) -> None: ...
if sys.version_info < (3, 2):
def help_help(self) -> None: ...
def help_h(self) -> None: ...
def help_where(self) -> None: ...
def help_w(self) -> None: ...
def help_down(self) -> None: ...
def help_d(self) -> None: ...
def help_up(self) -> None: ...
def help_u(self) -> None: ...
def help_break(self) -> None: ...
def help_b(self) -> None: ...
def help_clear(self) -> None: ...
def help_cl(self) -> None: ...
def help_tbreak(self) -> None: ...
def help_enable(self) -> None: ...
def help_disable(self) -> None: ...
def help_ignore(self) -> None: ...
def help_condition(self) -> None: ...
def help_step(self) -> None: ...
def help_s(self) -> None: ...
def help_until(self) -> None: ...
def help_unt(self) -> None: ...
def help_next(self) -> None: ...
def help_n(self) -> None: ...
def help_return(self) -> None: ...
def help_r(self) -> None: ...
def help_continue(self) -> None: ...
def help_cont(self) -> None: ...
def help_c(self) -> None: ...
def help_jump(self) -> None: ...
def help_j(self) -> None: ...
def help_debug(self) -> None: ...
def help_list(self) -> None: ...
def help_l(self) -> None: ...
def help_args(self) -> None: ...
def help_a(self) -> None: ...
def help_p(self) -> None: ...
def help_pp(self) -> None: ...
def help_run(self) -> None: ...
def help_quit(self) -> None: ...
def help_q(self) -> None: ...
def help_whatis(self) -> None: ...
def help_EOF(self) -> None: ...
def help_alias(self) -> None: ...
def help_unalias(self) -> None: ...
def help_commands(self) -> None: ...
help_bt = help_w
help_restart = help_run
help_exit = help_q
if sys.version_info >= (3, 2):
def sigint_handler(self, signum: signal.Signals, frame: FrameType) -> None: ...
def message(self, msg: str) -> None: ...
def error(self, msg: str) -> None: ...
def _select_frame(self, number: int) -> None: ...
def _getval_except(self, arg: str, frame: Optional[FrameType] = ...) -> object: ...
def _print_lines(
self, lines: Sequence[str], start: int, breaks: Sequence[int], frame: Optional[FrameType] = ...
) -> None: ...
def _cmdloop(self) -> None: ...
def do_display(self, arg: str) -> Optional[bool]: ...
def do_interact(self, arg: str) -> Optional[bool]: ...
def do_longlist(self, arg: str) -> Optional[bool]: ...
def do_source(self, arg: str) -> Optional[bool]: ...
def do_undisplay(self, arg: str) -> Optional[bool]: ...
do_ll = do_longlist
if sys.version_info >= (3, 3):
def _complete_location(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ...
def _complete_bpnumber(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ...
def _complete_expression(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ...
def complete_undisplay(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ...
def complete_unalias(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: ...
complete_commands = _complete_bpnumber
complete_break = _complete_location
complete_b = _complete_location
complete_tbreak = _complete_location
complete_enable = _complete_bpnumber
complete_disable = _complete_bpnumber
complete_condition = _complete_bpnumber
complete_ignore = _complete_bpnumber
complete_clear = _complete_location
complete_cl = _complete_location
complete_debug = _complete_expression
complete_print = _complete_expression
complete_p = _complete_expression
complete_pp = _complete_expression
complete_source = _complete_expression
complete_whatis = _complete_expression
complete_display = _complete_expression
if sys.version_info >= (3, 7):
def _runmodule(self, module_name: str) -> None: ...
if sys.version_info >= (3,) and sys.version_info < (3, 4):
do_print = do_p
# undocumented
def find_function(funcname: str, filename: str) -> Optional[Tuple[str, str, int]]: ...
def main() -> None: ...
def help() -> None: ...
if sys.version_info >= (3, 2):
def getsourcelines(obj: _SourceObjectType) -> Tuple[List[str], int]: ...
def lasti2lineno(code: CodeType, lasti: int) -> int: ...
class _rstr(str):
def __repr__(self) -> _rstr: ...