Skip to content

Commit b6f03bf

Browse files
committed
fix typing
1 parent ae998d3 commit b6f03bf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

jupyter_client/manager.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class _ShutdownStatus(Enum):
5757
F = t.TypeVar('F', bound=t.Callable[..., t.Any])
5858

5959

60-
def in_pending_state(prefix=''):
60+
def in_pending_state(prefix: str = '') -> t.Callable[[F], F]:
6161
def decorator(method: F) -> F:
6262
"""Sets the kernel to a pending state by
6363
creating a fresh Future for the KernelManager's `ready`
@@ -117,8 +117,8 @@ def _emit(self, *, action: str) -> None:
117117
data={"action": action, "kernel_id": self.kernel_id, "caller": "kernel_manager"},
118118
)
119119

120-
_ready: CFuture
121-
_shutdown_ready: CFuture
120+
_ready: t.Optional[CFuture]
121+
_shutdown_ready: t.Optional[CFuture]
122122

123123
def __init__(self, *args, **kwargs):
124124
super().__init__(**kwargs)
@@ -142,7 +142,7 @@ def _context_default(self) -> zmq.Context:
142142
)
143143
client_factory: Type = Type(klass="jupyter_client.KernelClient")
144144

145-
_future_factory = Future
145+
_future_factory: t.Type[CFuture] = CFuture
146146

147147
@default("client_factory") # type:ignore[misc]
148148
def _client_factory_default(self) -> Type:
@@ -213,13 +213,15 @@ def ready(self) -> CFuture:
213213
"""A future that resolves when the kernel process has started."""
214214
if not self._ready:
215215
self._ready = self._future_factory()
216+
assert self._ready is not None
216217
return self._ready
217218

218219
@property
219220
def shutdown_ready(self) -> CFuture:
220221
"""A future that resolves when the kernel process has shut down."""
221222
if not self._shutdown_ready:
222223
self._shutdown_ready = self._future_factory()
224+
assert self._shutdown_ready is not None
223225
return self._shutdown_ready
224226

225227
@property
@@ -694,7 +696,7 @@ class AsyncKernelManager(KernelManager):
694696
# The PyZMQ Context to use for communication with the kernel.
695697
context: Instance = Instance(zmq.asyncio.Context)
696698

697-
_future_factory = Future
699+
_future_factory: t.Type[Future] = Future # type:ignore[assignment]
698700

699701
@default("context") # type:ignore[misc]
700702
def _context_default(self) -> zmq.asyncio.Context:

0 commit comments

Comments
 (0)