colour.hints.Self#

colour.hints.Self = typing.Self[source]#

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