diff --git a/stdlib/3/_tracemalloc.pyi b/stdlib/3/_tracemalloc.pyi index e8a7168a3..3651c9319 100644 --- a/stdlib/3/_tracemalloc.pyi +++ b/stdlib/3/_tracemalloc.pyi @@ -1,16 +1,12 @@ -"""Stub file for the '_tracemalloc' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. +from typing import Optional, Sequence, Tuple +from tracemalloc import _TraceTupleT, _FrameTupleT -from typing import Any, Tuple - -def _get_object_traceback(*args, **kwargs) -> Any: ... -def _get_traces() -> Any: ... +def _get_object_traceback(__obj) -> Optional[Sequence[_FrameTupleT]]: ... +def _get_traces() -> Sequence[_TraceTupleT]: ... def clear_traces() -> None: ... def get_traceback_limit() -> int: ... -def get_traced_memory() -> Tuple[Any, ...]: ... -def get_tracemalloc_memory() -> Any: ... +def get_traced_memory() -> Tuple[int, int]: ... +def get_tracemalloc_memory() -> int: ... def is_tracing() -> bool: ... -def start(*args, **kwargs) -> None: ... +def start(__nframe: int = ...) -> None: ... def stop() -> None: ... diff --git a/stdlib/3/tracemalloc.pyi b/stdlib/3/tracemalloc.pyi index e09dccce6..de9d5150b 100644 --- a/stdlib/3/tracemalloc.pyi +++ b/stdlib/3/tracemalloc.pyi @@ -2,15 +2,9 @@ import sys from typing import List, Optional, Sequence, Tuple, Union, overload +from _tracemalloc import * -def clear_traces() -> None: ... def get_object_traceback(obj: object) -> Optional[Traceback]: ... -def get_traceback_limit() -> int: ... -def get_traced_memory() -> Tuple[int, int]: ... -def get_tracemalloc_memory() -> int: ... -def is_tracing() -> bool: ... -def start(__nframe: int = ...) -> None: ... -def stop() -> None: ... def take_snapshot() -> Snapshot: ... if sys.version_info >= (3, 6): @@ -31,25 +25,6 @@ class Filter: else: def __init__(self, inclusive: bool, filename_pattern: str, lineno: Optional[int] = ..., all_frames: bool = ...) -> None: ... -class Frame: - filename: str - lineno: int - def __init__(self, frame: Tuple[str, int]) -> None: ... - -class Snapshot: - def __init__(self, traces: Tuple[Tuple[str, int], ...], traceback_limit: int) -> None: ... - def compare_to(self, old_snapshot: Snapshot, key_type: str, cumulative: bool = ...) -> List[StatisticDiff]: ... - def dump(self, filename: str) -> None: ... - if sys.version_info >= (3, 6): - def filter_traces(self, filters: Sequence[Union[DomainFilter, Filter]]) -> Snapshot: ... - else: - def filter_traces(self, filters: Sequence[Filter]) -> Snapshot: ... - @staticmethod - def load(filename: str) -> Snapshot: ... - def statistics(self, key_type: str, cumulative: bool = ...) -> List[Statistic]: ... - traceback_limit: int - traces: Sequence[Trace] - class Statistic: count: int size: int @@ -64,21 +39,30 @@ class StatisticDiff: traceback: Traceback def __init__(self, traceback: Traceback, size: int, size_diff: int, count: int, count_diff: int) -> None: ... +_FrameTupleT = Tuple[str, int] + +class Frame: + filename: str + lineno: int + def __init__(self, frame: _FrameTupleT) -> None: ... + +if sys.version_info >= (3, 9): + _TraceTupleT = Union[Tuple[int, int, Sequence[_FrameTupleT], Optional[int]], Tuple[int, int, Sequence[_FrameTupleT]]] +else: + _TraceTupleT = Tuple[int, int, Sequence[_FrameTupleT]] + class Trace: domain: int size: int traceback: Traceback - if sys.version_info >= (3, 9): - def __init__(self, trace: Union[Tuple[int, int, Tuple[Tuple[str, int], ...], Optional[int]], Tuple[int, int, Tuple[Tuple[str, int], ...]]]) -> None: ... - else: - def __init__(self, trace: Tuple[int, int, Tuple[Tuple[str, int], ...]]) -> None: ... + def __init__(self, trace: _TraceTupleT) -> None: ... class Traceback(Sequence[Frame]): if sys.version_info >= (3, 9): total_nframe: Optional[int] - def __init__(self, frames: Tuple[Tuple[str, int], ...], total_nframe: Optional[int] = ...) -> None: ... + def __init__(self, frames: Sequence[_FrameTupleT], total_nframe: Optional[int] = ...) -> None: ... else: - def __init__(self, frames: Tuple[Tuple[str, int], ...]) -> None: ... + def __init__(self, frames: Sequence[_FrameTupleT]) -> None: ... if sys.version_info >= (3, 7): def format(self, limit: Optional[int] = ..., most_recent_first: bool = ...) -> List[str]: ... else: @@ -88,3 +72,18 @@ class Traceback(Sequence[Frame]): @overload def __getitem__(self, s: slice) -> Sequence[Frame]: ... def __len__(self) -> int: ... + + +class Snapshot: + def __init__(self, traces: Sequence[_TraceTupleT], traceback_limit: int) -> None: ... + def compare_to(self, old_snapshot: Snapshot, key_type: str, cumulative: bool = ...) -> List[StatisticDiff]: ... + def dump(self, filename: str) -> None: ... + if sys.version_info >= (3, 6): + def filter_traces(self, filters: Sequence[Union[DomainFilter, Filter]]) -> Snapshot: ... + else: + def filter_traces(self, filters: Sequence[Filter]) -> Snapshot: ... + @staticmethod + def load(filename: str) -> Snapshot: ... + def statistics(self, key_type: str, cumulative: bool = ...) -> List[Statistic]: ... + traceback_limit: int + traces: Sequence[Trace] diff --git a/tests/stubtest_whitelists/py37.txt b/tests/stubtest_whitelists/py37.txt index 03ff5b36f..2649ed1fb 100644 --- a/tests/stubtest_whitelists/py37.txt +++ b/tests/stubtest_whitelists/py37.txt @@ -1,5 +1,3 @@ -_tracemalloc._get_object_traceback -_tracemalloc.start asyncio.AbstractEventLoop.sock_sendfile asyncio.Future.__init__ asyncio.Future._callbacks diff --git a/tests/stubtest_whitelists/py38.txt b/tests/stubtest_whitelists/py38.txt index d264cfbf0..bbdb0a3ac 100644 --- a/tests/stubtest_whitelists/py38.txt +++ b/tests/stubtest_whitelists/py38.txt @@ -1,7 +1,5 @@ _thread.ExceptHookArgs _thread._ExceptHookArgs -_tracemalloc._get_object_traceback -_tracemalloc.start ast.Bytes.__new__ ast.Ellipsis.__new__ ast.NameConstant.__new__ diff --git a/tests/stubtest_whitelists/py39.txt b/tests/stubtest_whitelists/py39.txt index bdbcd0641..67098c1aa 100644 --- a/tests/stubtest_whitelists/py39.txt +++ b/tests/stubtest_whitelists/py39.txt @@ -2,8 +2,6 @@ _ast.ImportFrom.level _dummy_thread _thread.ExceptHookArgs _thread._ExceptHookArgs -_tracemalloc._get_object_traceback -_tracemalloc.start _weakref.getweakrefcount aifc.openfp array.array.fromstring