Python 3.5+Annotations & typingterm
typing.Any
any
A special type compatible with every other type. It turns type checking off. Used when migrating code or for genuinely dynamic values.
Syntax
from typing import Any
x: Any = ...
Any is contagious: anything you pull out of an Any value is Any as well, so type checking quietly evaporates across a whole region of code and one lazy annotation can undo the typing of an entire module. If you really mean "any object at all" but intend to handle it carefully, object is the honest choice — the checker will then force you to narrow before calling methods. Treat Any as a deliberate "checking off here", not as a placeholder for a type you have not worked out yet.
Examples
# Python 3.9+
from typing import Any
def log(value: Any) -> None: print(value)
log(42) # → 42
log('text') # → text
log([1, 2, 3]) # → [1, 2, 3]
data: list[Any] = [1, 'a', None, 3.14] # смешанный список
print(type(data[0])) # → <class 'int'>
print(Any) # → typing.Any
See also
Open in the full glossarydocs.python.orgReport an inaccuracy