On this page
typing.clear_overloads
Prev: typing.ClassVar | Up: typing | Next: typing.Collection
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.clear_overloads
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import clear_overloads
Signature & Overview
typing.clear_overloads()
Clear all overloads in the registry.
Usage
from typing import clear_overloads, get_overloads, overload
@overload
def f(x: int) -> int: ...
@overload
def f(x: str) -> str: ...
def f(x): return x
assert len(get_overloads(f)) == 2
clear_overloads()
assert len(get_overloads(f)) == 0
Gotchas
- Requires Python 3.11+: Clears the global runtime overload registry (mainly to free memory or reset state in tests).
REPL Inspect
from typing import clear_overloads
help(clear_overloads)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/ClassVar Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Collection Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/typing/AbstractSet Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Annotated Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Any Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_never Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_type shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncContextManager shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncGenerator shared tags: #stdlib, #typing