From c36c7c8848c45d8d3bc88d73411a1be6c64574fa Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 22 Jun 2021 20:04:01 +0200 Subject: [PATCH] Add Self type var to _typeshed Cf. #5676 --- stdlib/@python2/_typeshed/__init__.pyi | 4 ++++ stdlib/_typeshed/__init__.pyi | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/stdlib/@python2/_typeshed/__init__.pyi b/stdlib/@python2/_typeshed/__init__.pyi index 9548a2497943..ca698e29ae8a 100644 --- a/stdlib/@python2/_typeshed/__init__.pyi +++ b/stdlib/@python2/_typeshed/__init__.pyi @@ -26,6 +26,10 @@ _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) _T_contra = TypeVar("_T_contra", contravariant=True) +# Use for "self" annotations: +# def __enter__(self: Self) -> Self: ... +Self = TypeVar("Self") # noqa Y001 + class IdentityFunction(Protocol): def __call__(self, __x: _T) -> _T: ... diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index 26cbddcb8104..69d1c7c1618e 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -18,6 +18,10 @@ _T = TypeVar("_T") _T_co = TypeVar("_T_co", covariant=True) _T_contra = TypeVar("_T_contra", contravariant=True) +# Use for "self" annotations: +# def __enter__(self: Self) -> Self: ... +Self = TypeVar("Self") # noqa Y001 + # stable class IdentityFunction(Protocol): def __call__(self, __x: _T) -> _T: ...