On this page
  1. typing.Callable
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

typing.Callable

Prev: typing.ByteString | Up: typing | Next: typing.cast
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.Callable
Tags: #public #python3 #stdlib #typing


Import

import typing
from typing import Callable

Signature & Overview

typing.Callable(*args, **kwargs)

Deprecated alias to collections.abc.Callable.

Usage

from typing import Callable

def apply(fn: Callable[[int, int], int], a: int, b: int) -> int:
    return fn(a, b)

assert apply(lambda x, y: x + y, 3, 4) == 7

Gotchas

REPL Inspect

from typing import Callable
help(Callable)

Linked from

Related notes