MCPcopy Index your code
hub / github.com/RustPython/RustPython / Self

Function Self

Lib/typing.py:653–669  ·  view source on GitHub ↗

Used to spell the type of "self" in classes. Example:: from typing import Self class Foo: def return_self(self) -> Self: ... return self This is especially useful for: - classmethods that are used as alternative construc

(self, parameters)

Source from the content-addressed store, hash-verified

651
652@_SpecialForm
653def Self(self, parameters):
654 """Used to spell the type of "self" in classes.
655
656 Example::
657
658 from typing import Self
659
660 class Foo:
661 def return_self(self) -> Self:
662 ...
663 return self
664
665 This is especially useful for:
666 - classmethods that are used as alternative constructors
667 - annotating an `__enter__` method which returns self
668 """
669 raise TypeError(f"{self} is not subscriptable")
670
671
672@_SpecialForm

Callers 15

test_cannot_initMethod · 0.90
try_from_objectMethod · 0.85
newMethod · 0.85
try_from_objectMethod · 0.85
fromMethod · 0.85
try_into_from_objectMethod · 0.85
byteswapMethod · 0.85
try_fromMethod · 0.85
try_from_pyintMethod · 0.85
newMethod · 0.85
fromMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_cannot_initMethod · 0.72