Typing and Generics

typing.clear_overloads

Clears typing's overload registry, affecting subsequent introspection of all registered overloads in the current interpreter. Runtime implementations continue working. Added in 3.11. Use only when the registry is no longer needed.

Formal Syntax & Structure

python syntaxpython
typing.clear_overloads()

Return Value

None

Typing construct or runtime result as described; static typing rules are not runtime validation.

Working Example

Example Snippetpython
from typing import clear_overloads, get_overloads, overload
clear_overloads()@overloaddef sample(x:int)->int: ...@overloaddef sample(x:str)->str: ...def sample(x:int|str)->int|str: return xbefore=len(get_overloads(sample))result=clear_overloads()print((before,len(get_overloads(sample)),result))
Python Reference