Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/nbclient/util.py: 50%

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

12 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 typing import Any, Callable 

9 

10from jupyter_core.utils import ensure_async, run_sync 

11 

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

13 

14 

15async def run_hook(hook: Callable[..., Any] | None, **kwargs: Any) -> None: 

16 """Run a hook callback.""" 

17 if hook is None: 

18 return 

19 res = hook(**kwargs) 

20 if inspect.isawaitable(res): 

21 await res