Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: typing.Self, fix typo #94771

Merged
Merged
Changes from 2 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