Skip to content

Commit 179a379

Browse files
authored
Type hints for Future.status (#9188)
1 parent 0935391 commit 179a379

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

distributed/client.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,22 @@ def executor(self):
358358
return self.client
359359

360360
@property
361-
def status(self):
361+
def status(
362+
self,
363+
) -> Literal["pending", "cancelled", "finished", "lost", "error"] | None:
362364
"""Returns the status
363365
364366
Returns
365367
-------
366-
str
367-
The status
368+
str or None
369+
The status of the future. Possible values:
370+
371+
- "pending": The future is waiting to be computed
372+
- "finished": The future has completed successfully
373+
- "error": The future encountered an error during computation
374+
- "cancelled": The future was cancelled
375+
- "lost": The future's data was lost from memory
376+
- None: The future is not yet bound to a client
368377
"""
369378
if self._state:
370379
return self._state.status
@@ -645,7 +654,9 @@ def __init__(self, key: str):
645654
self._event = None
646655
self.key = key
647656
self.exception = None
648-
self.status = "pending"
657+
self.status: Literal["pending", "cancelled", "finished", "lost", "error"] = (
658+
"pending"
659+
)
649660
self.traceback = None
650661
self.type = None
651662

0 commit comments

Comments
 (0)