Python 3.11+typingfunction
typing.clear_overloads
decorators and markers
Clear the internal registry of @overload implementations (returns None; 3.11+).
Syntax
typing.clear_overloads()
It exists as the counterpart to get_overloads: since 3.11 every @overload stashes its stub in an internal registry you can read back at runtime, and clear_overloads wipes that registry. It's mainly for library authors and tests — to free the retained references or restart overload collection from scratch — and you almost never need it in application code.
Examples
from typing import overload, get_overloads, clear_overloads
print(clear_overloads() is None) # → True
from typing import overload, get_overloads, clear_overloads
def dup(x: int) -> int: ... # заглушка будущей перегрузки
_ = overload(dup); print(len(get_overloads(dup))) # → 1
clear_overloads(); print(get_overloads(dup)) # → []
print(get_overloads(print)) # → []
See also
Open in the full glossarydocs.python.orgReport an inaccuracy