From 816a92b8e82a2fd035f9fcb528f8a1f8bd5de988 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 22 Jun 2021 22:15:27 +0200 Subject: [PATCH] Add Self type var to _typeshed (#5677) 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 9548a2497..ca698e29a 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 26cbddcb8..69d1c7c16 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: ...