Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ These can be used as types in annotations and do not support ``[]``.
from typing import Self

class Foo:
def returns_self(self) -> Self:
def return_self(self) -> Self:
...
return self

Expand All @@ -696,7 +696,7 @@ These can be used as types in annotations and do not support ``[]``.
Self = TypeVar("Self", bound="Foo")

class Foo:
def returns_self(self: Self) -> Self:
def return_self(self: Self) -> Self:
...
return self

Expand All @@ -707,7 +707,7 @@ These can be used as types in annotations and do not support ``[]``.
...
return self

You should use use :data:`Self` as calls to ``SubclassOfFoo.returns_self`` would have
You should use :data:`Self` as calls to ``SubclassOfFoo.return_self`` would have
``Foo`` as the return type and not ``SubclassOfFoo``.

Other common use cases include:
Expand Down
2 changes: 1 addition & 1 deletion Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def Self(self, parameters):
from typing import Self

class Foo:
def returns_self(self) -> Self:
def return_self(self) -> Self:
...
return self

Expand Down