diff --git a/stdlib/3/inspect.pyi b/stdlib/3/inspect.pyi index d4fae4b71..9286aa04f 100644 --- a/stdlib/3/inspect.pyi +++ b/stdlib/3/inspect.pyi @@ -1,6 +1,7 @@ # Stubs for inspect from typing import Any, Tuple, List, Callable +from types import FrameType _object = object @@ -29,3 +30,5 @@ class ArgSpec(tuple): defaults = ... # type: tuple def getargspec(func: object) -> ArgSpec: ... + +def stack() -> List[Tuple[FrameType, str, int, str, List[str], int]]: ... diff --git a/stdlib/3/types.pyi b/stdlib/3/types.pyi index 866f05d44..80f4ac02c 100644 --- a/stdlib/3/types.pyi +++ b/stdlib/3/types.pyi @@ -2,7 +2,7 @@ # TODO this is work in progress -from typing import Any +from typing import Any, Callable, Dict, Sequence class ModuleType: __name__ = ... # type: str @@ -12,8 +12,55 @@ class ModuleType: class MethodType: ... class BuiltinMethodType: ... +class CodeType: + """Create a code object. Not for the faint of heart.""" + def __init__(self, + argcount: int, + kwonlyargcount: int, + nlocals: int, + stacksize: int, + flags: int, + codestring: bytes, + constants: Sequence[Any], + names: Sequence[str], + varnames: Sequence[str], + filename: str, + name: str, + firstlineno: int, + lnotab: bytes, + freevars: Sequence[str] = (), + cellvars: Sequence[str] = (), + ) -> None: + self.co_argcount = argcount + self.co_kwonlyargcount = kwonlyargcount + self.co_nlocals = nlocals + self.co_stacksize = stacksize + self.co_flags = flags + self.co_code = codestring + self.co_consts = constants + self.co_names = names + self.co_varnames = varnames + self.co_filename = filename + self.co_name = name + self.co_firstlineno = firstlineno + self.co_lnotab = lnotab + self.co_freevars = freevars + self.co_cellvars = cellvars + +class FrameType: + f_back = ... # type: FrameType + f_builtins = ... # type: Dict[str, Any] + f_code = ... # type: CodeType + f_globals = ... # type: Dict[str, Any] + f_lasti = ... # type: int + f_lineno = ... # type: int + f_locals = ... # type: Dict[str, Any] + f_trace = ... # type: Callable[[], None] + + def clear(self) -> None: pass + class TracebackType: - tb_frame = ... # type: Any + tb_frame = ... # type: FrameType tb_lasti = ... # type: int tb_lineno = ... # type: int - tb_next = ... # type: Any + tb_next = ... # type: TracebackType