Typing and Generics
typing.get_overloads
Returns registered overload declaration functions for a runtime implementation, or an empty list when none are registered. It exposes metadata, not runtime overload dispatch. Added in 3.11.
Formal Syntax & Structure
python syntaxpython
typing.get_overloads(func)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| func | callable | Runtime implementation. |
Return Value
list
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 convert(x:int)->str: ...@overloaddef convert(x:str)->str: ...def convert(x:int|str)->str: return str(x)print(len(get_overloads(convert)))