Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 262d73c

Browse files
authored
Update description of _typeshed.Self (#11233)
1 parent 54447f6 commit 262d73c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

stdlib/_typeshed/__init__.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ _T = TypeVar("_T")
1919
_T_co = TypeVar("_T_co", covariant=True)
2020
_T_contra = TypeVar("_T_contra", contravariant=True)
2121

22-
# Use for "self" annotations:
23-
# def __enter__(self: Self) -> Self: ...
22+
# Alternative to `typing_extensions.Self`, exclusively for use with `__new__`
23+
# in metaclasses:
24+
# def __new__(cls: type[Self], ...) -> Self: ...
25+
# In other cases, use `typing_extensions.Self`.
2426
Self = TypeVar("Self") # noqa: Y001
2527

2628
# covariant version of typing.AnyStr, useful for protocols

0 commit comments

Comments
 (0)