-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[typing] update prefect.futures
#16381
Conversation
CodSpeed Performance ReportMerging #16381 will not alter performanceComparing Summary
|
prefect.futures
prefect.futures
6a047a1
to
74094f9
Compare
74094f9
to
bbb393b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
try: | ||
with timeout_context(timeout): | ||
done = {f for f in unique_futures if f._final_state} | ||
done = {f for f in unique_futures if f._final_state} # type: ignore[privateUsage] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the PrefectFuture
class should have a public read-only property or method for this? Also, I find getattr()
helpful to hide private access from the type checker 😇
|
||
def _collect_futures(futures, expr, context): | ||
def _collect_futures( | ||
futures: set[PrefectFuture[R]], expr: Any, context: Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context
must at least support .get(str)
so I think it should be a Mapping[str, Any]
, certainly given what I've seen of how contexts are used in perfect. Ditto in other argument annotations below.
@@ -455,14 +470,14 @@ def _collect_futures(futures, expr, context): | |||
return expr | |||
|
|||
# Get final states for each future | |||
states = [] | |||
states: list[State] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State is generic, so this is missing a parameter.
states: list[State] = [] | |
states: list[State[Any]] = [] |
related to #16292
updates typing of wait and
DoneAndNotDoneFutures