Skip to content

Commit

Permalink
docs: typing.Self, fix typo (pythonGH-94771)
Browse files Browse the repository at this point in the history
* fix typo - double spelled word 'use'

* change methods names to the infinitive form
(cherry picked from commit 90a6e56)

Co-authored-by: Max Zhenzhera <[email protected]>
  • Loading branch information
maxzhenzhera authored and miss-islington committed Jul 12, 2022
1 parent cdd0cab commit 941aa92
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 941aa92

Please sign in to comment.