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,10 +1,9 @@
import sys
from _typeshed import Self
from collections.abc import Awaitable, Callable, Coroutine, Iterable, Mapping, Sequence
from contextlib import _GeneratorContextManager
from types import TracebackType
from typing import Any, Generic, TypeVar, overload
from typing_extensions import Literal, TypeAlias
from typing_extensions import Literal, Self, TypeAlias
_T = TypeVar("_T")
_TT = TypeVar("_TT", bound=type[Any])
@@ -68,12 +67,7 @@ _CallValue: TypeAlias = str | tuple[Any, ...] | Mapping[str, Any] | _ArgsKwargs
class _Call(tuple[Any, ...]):
def __new__(
cls: type[Self],
value: _CallValue = ...,
name: str | None = "",
parent: Any | None = None,
two: bool = False,
from_kall: bool = True,
cls, value: _CallValue = ..., name: str | None = "", parent: Any | None = None, two: bool = False, from_kall: bool = True
) -> Self: ...
name: Any
parent: Any
@@ -108,7 +102,7 @@ class Base:
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class NonCallableMock(Base, Any):
def __new__(__cls: type[Self], *args: Any, **kw: Any) -> Self: ...
def __new__(__cls, *args: Any, **kw: Any) -> Self: ...
def __init__(
self,
spec: list[str] | object | type[object] | None = None,
@@ -437,9 +431,9 @@ def mock_open(mock: Any | None = None, read_data: Any = "") -> Any: ...
class PropertyMock(Mock):
if sys.version_info >= (3, 8):
def __get__(self: Self, obj: _T, obj_type: type[_T] | None = None) -> Self: ...
def __get__(self, obj: _T, obj_type: type[_T] | None = None) -> Self: ...
else:
def __get__(self: Self, obj: _T, obj_type: type[_T] | None) -> Self: ...
def __get__(self, obj: _T, obj_type: type[_T] | None) -> Self: ...
def __set__(self, obj: Any, value: Any) -> None: ...