From 7c80c52a7a4b3b696725acf6d768b2643e8f326f Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Sat, 16 Mar 2019 14:14:16 -0700 Subject: [PATCH] Add missing class pdb.Pdb. (#2872) Based on: https://docs.python.org/3/library/pdb.html#pdb.Pdb, with the one difference that the `skip` argument to the constructor is present in 2.7 despite being listed as new in 3.1. --- stdlib/2and3/pdb.pyi | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/stdlib/2and3/pdb.pyi b/stdlib/2and3/pdb.pyi index d63eaf0a6..e403c36ca 100644 --- a/stdlib/2and3/pdb.pyi +++ b/stdlib/2and3/pdb.pyi @@ -1,7 +1,11 @@ # NOTE: This stub is incomplete - only contains some global functions +from cmd import Cmd import sys -from typing import Any, Dict, Optional +from types import FrameType +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar + +_T = TypeVar('_T') class Restart(Exception): ... @@ -19,3 +23,40 @@ else: def post_mortem(t: Optional[Any] = ...) -> None: ... def pm() -> None: ... + +class Pdb(Cmd): + if sys.version_info >= (3, 6): + def __init__( + self, + completekey: str = ..., + stdin: Optional[IO[str]] = ..., + stdout: Optional[IO[str]] = ..., + skip: Optional[Iterable[str]] = ..., + nosigint: bool = ..., + readrc: bool = ..., + ) -> None: ... + elif sys.version_info >= (3, 2): + def __init__( + self, + completekey: str = ..., + stdin: Optional[IO[str]] = ..., + stdout: Optional[IO[str]] = ..., + skip: Optional[Iterable[str]] = ..., + nosigint: bool = ..., + ) -> None: ... + else: + def __init__( + self, + completekey: str = ..., + stdin: Optional[IO[str]] = ..., + 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: ...