Skip to content

Commit 816a92b

Browse files
authored
Add Self type var to _typeshed (#5677)
Cf. #5676
1 parent 73b4c21 commit 816a92b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

stdlib/@python2/_typeshed/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ _T = TypeVar("_T")
2626
_T_co = TypeVar("_T_co", covariant=True)
2727
_T_contra = TypeVar("_T_contra", contravariant=True)
2828

29+
# Use for "self" annotations:
30+
# def __enter__(self: Self) -> Self: ...
31+
Self = TypeVar("Self") # noqa Y001
32+
2933
class IdentityFunction(Protocol):
3034
def __call__(self, __x: _T) -> _T: ...
3135

stdlib/_typeshed/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ _T = TypeVar("_T")
1818
_T_co = TypeVar("_T_co", covariant=True)
1919
_T_contra = TypeVar("_T_contra", contravariant=True)
2020

21+
# Use for "self" annotations:
22+
# def __enter__(self: Self) -> Self: ...
23+
Self = TypeVar("Self") # noqa Y001
24+
2125
# stable
2226
class IdentityFunction(Protocol):
2327
def __call__(self, __x: _T) -> _T: ...

0 commit comments

Comments
 (0)