Skip to content

Instantly share code, notes, and snippets.

@2tony2
Created May 22, 2024 07:20
Show Gist options
  • Select an option

  • Save 2tony2/9a0f0ff577e8bcab2215ac92a548918e to your computer and use it in GitHub Desktop.

Select an option

Save 2tony2/9a0f0ff577e8bcab2215ac92a548918e to your computer and use it in GitHub Desktop.
from collections.abc import Callable, Awaitable
# Function with callable parameter
def feeder(get_next_item: Callable[[], str]) -> None:
... # Body
# Function with multiple callable parameters
def async_query(on_success: Callable[[int], None],
on_error: Callable[[int, Exception], None]) -> None:
... # Body
# Async function example
async def on_update(value: str) -> None:
... # Body
callback: Callable[[str], Awaitable[None]] = on_update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment