Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/nbclient/util.py: 54%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""General utility methods"""
3# Copyright (c) Jupyter Development Team.
4# Distributed under the terms of the Modified BSD License.
5from __future__ import annotations
7import inspect
8from collections.abc import Callable
9from typing import Any
11from jupyter_core.utils import ensure_async, run_sync
13__all__ = ["ensure_async", "run_sync", "run_hook"]
16async def run_hook(hook: Callable[..., Any] | None, **kwargs: Any) -> None:
17 """Run a hook callback."""
18 if hook is None:
19 return
20 res = hook(**kwargs)
21 if inspect.isawaitable(res):
22 await res