CKTIS / Python
typing.Callable
Describe a callable by its parameter types and return type.
Version: Python 3.14; repository image, production runtime not attested
Syntax
Callable[[int, int], str]Describe a callable by its parameter types and return type.
Ellipsis in the argument position leaves the parameter list unspecified, while a list describes positional arguments. In Python 3.14 typing.Callable is a deprecated alias of collections.abc.Callable.
A callable object can pass a basic callability test yet reject the arguments at the actual call.
Examples
from typing import Callable
from collections.abc import Callable as CallableABC
def run(fn: Callable[[int, int], str]) -> str:
return fn(2, 4)
print(run(lambda a, b: str(a + b)))
bad = lambda: "empty"
print(isinstance(bad, CallableABC))
try:
run(bad)
except TypeError:
print("wrong arity")
Result
6 True wrong arity
A callable object can pass a basic callability test yet reject the arguments at the actual call.