PyDocs

Nav

Development Tools

Self

typing

data · Added in 3.11
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 constructors
    - annotating an `__enter__` method which returns self
0 Examples
No examples for typing/Self.
See Also
No see-alsos for typing/Self
0 Notes
No notes for Self