Skip to content

Commit 25fe1d5

Browse files
authored
Merge pull request #278 from blink1073/fix-completions
2 parents a481add + a1a7db1 commit 25fe1d5

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

jupyter_console/completer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from traitlets.config import Configurable
88
from traitlets import Float
99

10-
from jupyter_client.utils import run_sync
10+
from jupyter_console.utils import run_sync
1111

1212

1313
class ZMQCompleter(Configurable):

jupyter_console/ptshell.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import sys
1414
from tempfile import TemporaryDirectory
1515
import time
16-
import typing as t
1716
from warnings import warn
1817

1918
from typing import Dict as DictType, Any as AnyType
@@ -31,7 +30,6 @@
3130
Instance,
3231
Any,
3332
)
34-
import inspect
3533
from traitlets.config import SingletonConfigurable
3634

3735
from .completer import ZMQCompleter
@@ -78,29 +76,7 @@
7876
from pygments.util import ClassNotFound
7977
from pygments.token import Token
8078

81-
from jupyter_core.utils import run_sync as _run_sync
82-
83-
84-
T = t.TypeVar("T")
85-
86-
87-
def run_sync(coro: t.Callable[..., t.Union[T, t.Awaitable[T]]]) -> t.Callable[..., T]:
88-
"""Wraps coroutine in a function that blocks until it has executed.
89-
90-
Parameters
91-
----------
92-
coro : coroutine-function
93-
The coroutine-function to be executed.
94-
95-
Returns
96-
-------
97-
result :
98-
Whatever the coroutine-function returns.
99-
"""
100-
if not inspect.iscoroutinefunction(coro):
101-
return t.cast(t.Callable[..., T], coro)
102-
return _run_sync(coro)
103-
79+
from jupyter_console.utils import run_sync
10480

10581

10682
def ask_yes_no(prompt, default=None, interrupt=None):

jupyter_console/utils.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import inspect
2+
import typing as t
3+
from jupyter_core.utils import run_sync as _run_sync
4+
5+
6+
T = t.TypeVar("T")
7+
8+
9+
def run_sync(coro: t.Callable[..., t.Union[T, t.Awaitable[T]]]) -> t.Callable[..., T]:
10+
"""Wraps coroutine in a function that blocks until it has executed.
11+
12+
Parameters
13+
----------
14+
coro : coroutine-function
15+
The coroutine-function to be executed.
16+
17+
Returns
18+
-------
19+
result :
20+
Whatever the coroutine-function returns.
21+
"""
22+
if not inspect.iscoroutinefunction(coro):
23+
return t.cast(t.Callable[..., T], coro)
24+
return _run_sync(coro)
25+

0 commit comments

Comments
 (0)