@@ -57,7 +57,7 @@ class _ShutdownStatus(Enum):
57
57
F = t .TypeVar ('F' , bound = t .Callable [..., t .Any ])
58
58
59
59
60
- def in_pending_state (prefix = '' ):
60
+ def in_pending_state (prefix : str = '' ) -> t . Callable [[ F ], F ] :
61
61
def decorator (method : F ) -> F :
62
62
"""Sets the kernel to a pending state by
63
63
creating a fresh Future for the KernelManager's `ready`
@@ -117,8 +117,8 @@ def _emit(self, *, action: str) -> None:
117
117
data = {"action" : action , "kernel_id" : self .kernel_id , "caller" : "kernel_manager" },
118
118
)
119
119
120
- _ready : CFuture
121
- _shutdown_ready : CFuture
120
+ _ready : t . Optional [ CFuture ]
121
+ _shutdown_ready : t . Optional [ CFuture ]
122
122
123
123
def __init__ (self , * args , ** kwargs ):
124
124
super ().__init__ (** kwargs )
@@ -142,7 +142,7 @@ def _context_default(self) -> zmq.Context:
142
142
)
143
143
client_factory : Type = Type (klass = "jupyter_client.KernelClient" )
144
144
145
- _future_factory = Future
145
+ _future_factory : t . Type [ CFuture ] = CFuture
146
146
147
147
@default ("client_factory" ) # type:ignore[misc]
148
148
def _client_factory_default (self ) -> Type :
@@ -213,13 +213,15 @@ def ready(self) -> CFuture:
213
213
"""A future that resolves when the kernel process has started."""
214
214
if not self ._ready :
215
215
self ._ready = self ._future_factory ()
216
+ assert self ._ready is not None
216
217
return self ._ready
217
218
218
219
@property
219
220
def shutdown_ready (self ) -> CFuture :
220
221
"""A future that resolves when the kernel process has shut down."""
221
222
if not self ._shutdown_ready :
222
223
self ._shutdown_ready = self ._future_factory ()
224
+ assert self ._shutdown_ready is not None
223
225
return self ._shutdown_ready
224
226
225
227
@property
@@ -694,7 +696,7 @@ class AsyncKernelManager(KernelManager):
694
696
# The PyZMQ Context to use for communication with the kernel.
695
697
context : Instance = Instance (zmq .asyncio .Context )
696
698
697
- _future_factory = Future
699
+ _future_factory : t . Type [ Future ] = Future # type:ignore[assignment]
698
700
699
701
@default ("context" ) # type:ignore[misc]
700
702
def _context_default (self ) -> zmq .asyncio .Context :
0 commit comments