Use typing_extensions.Self in the stdlib (#9694)

This commit is contained in:
Alex Waygood
2023-02-09 09:12:13 +00:00
committed by GitHub
parent 10086c06a1
commit 9ed39d8796
98 changed files with 627 additions and 654 deletions

View File

@@ -1,11 +1,11 @@
import sys
from _typeshed import Self, StrOrBytesPath
from _typeshed import StrOrBytesPath
from collections.abc import Iterable
from cProfile import Profile as _cProfile
from enum import Enum
from profile import Profile
from typing import IO, Any, overload
from typing_extensions import Literal, TypeAlias
from typing_extensions import Literal, Self, TypeAlias
if sys.version_info >= (3, 9):
__all__ = ["Stats", "SortKey", "FunctionProfile", "StatsProfile"]
@@ -47,7 +47,7 @@ _SortArgDict: TypeAlias = dict[str, tuple[tuple[tuple[int, int], ...], str]]
class Stats:
sort_arg_dict_default: _SortArgDict
def __init__(
self: Self,
self,
__arg: None | str | Profile | _cProfile = ...,
*args: None | str | Profile | _cProfile | Self,
stream: IO[Any] | None = None,
@@ -55,24 +55,24 @@ class Stats:
def init(self, arg: None | str | Profile | _cProfile) -> None: ...
def load_stats(self, arg: None | str | Profile | _cProfile) -> None: ...
def get_top_level_stats(self) -> None: ...
def add(self: Self, *arg_list: None | str | Profile | _cProfile | Self) -> Self: ...
def add(self, *arg_list: None | str | Profile | _cProfile | Self) -> Self: ...
def dump_stats(self, filename: StrOrBytesPath) -> None: ...
def get_sort_arg_defs(self) -> _SortArgDict: ...
@overload
def sort_stats(self: Self, field: Literal[-1, 0, 1, 2]) -> Self: ...
def sort_stats(self, field: Literal[-1, 0, 1, 2]) -> Self: ...
@overload
def sort_stats(self: Self, *field: str) -> Self: ...
def reverse_order(self: Self) -> Self: ...
def strip_dirs(self: Self) -> Self: ...
def sort_stats(self, *field: str) -> Self: ...
def reverse_order(self) -> Self: ...
def strip_dirs(self) -> Self: ...
def calc_callees(self) -> None: ...
def eval_print_amount(self, sel: _Selector, list: list[str], msg: str) -> tuple[list[str], str]: ...
if sys.version_info >= (3, 9):
def get_stats_profile(self) -> StatsProfile: ...
def get_print_list(self, sel_list: Iterable[_Selector]) -> tuple[int, list[str]]: ...
def print_stats(self: Self, *amount: _Selector) -> Self: ...
def print_callees(self: Self, *amount: _Selector) -> Self: ...
def print_callers(self: Self, *amount: _Selector) -> Self: ...
def print_stats(self, *amount: _Selector) -> Self: ...
def print_callees(self, *amount: _Selector) -> Self: ...
def print_callers(self, *amount: _Selector) -> Self: ...
def print_call_heading(self, name_size: int, column_title: str) -> None: ...
def print_call_line(self, name_size: int, source: str, call_dict: dict[str, Any], arrow: str = "->") -> None: ...
def print_title(self) -> None: ...