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

13 statements  

1"""General utility methods""" 

2 

3# Copyright (c) Jupyter Development Team. 

4# Distributed under the terms of the Modified BSD License. 

5from __future__ import annotations 

6 

7import inspect 

8from collections.abc import Callable 

9from typing import Any 

10 

11from jupyter_core.utils import ensure_async, run_sync 

12 

13__all__ = ["ensure_async", "run_sync", "run_hook"] 

14 

15 

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