colour.hints.overload#

colour.hints.overload(func)[source]#

Decorator for overloaded functions/methods.

In a non-stub file, place two or more stub definitions for the same function in a row, each decorated with @overload, followed by an implementation. The implementation should not be decorated with @overload:

@overload
def utf8(value: None) -> None: ...
@overload
def utf8(value: bytes) -> bytes: ...
@overload
def utf8(value: str) -> bytes: ...
def utf8(value):
    ...  # implementation goes here

In a stub file or in an abstract method (for example, in a Protocol definition), the implementation may be omitted:

@overload
def utf8(value: None) -> None: ...
@overload
def utf8(value: bytes) -> bytes: ...
@overload
def utf8(value: str) -> bytes: ...

The overloads for a function can be retrieved at runtime using the get_overloads() function.