mirror of
https://github.com/python/cpython.git
synced 2025-09-18 22:50:26 +00:00
docs: typing.Self, fix typo (GH-94771)
* fix typo - double spelled word 'use' * change methods names to the infinitive form
This commit is contained in:
parent
0c66074e9f
commit
90a6e56e56
2 changed files with 4 additions and 4 deletions
|
@ -683,7 +683,7 @@ These can be used as types in annotations and do not support ``[]``.
|
||||||
from typing import Self
|
from typing import Self
|
||||||
|
|
||||||
class Foo:
|
class Foo:
|
||||||
def returns_self(self) -> Self:
|
def return_self(self) -> Self:
|
||||||
...
|
...
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -696,7 +696,7 @@ These can be used as types in annotations and do not support ``[]``.
|
||||||
Self = TypeVar("Self", bound="Foo")
|
Self = TypeVar("Self", bound="Foo")
|
||||||
|
|
||||||
class Foo:
|
class Foo:
|
||||||
def returns_self(self: Self) -> Self:
|
def return_self(self: Self) -> Self:
|
||||||
...
|
...
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -707,7 +707,7 @@ These can be used as types in annotations and do not support ``[]``.
|
||||||
...
|
...
|
||||||
return self
|
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``.
|
``Foo`` as the return type and not ``SubclassOfFoo``.
|
||||||
|
|
||||||
Other common use cases include:
|
Other common use cases include:
|
||||||
|
|
|
@ -569,7 +569,7 @@ def Self(self, parameters):
|
||||||
from typing import Self
|
from typing import Self
|
||||||
|
|
||||||
class Foo:
|
class Foo:
|
||||||
def returns_self(self) -> Self:
|
def return_self(self) -> Self:
|
||||||
...
|
...
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue