Skip to content
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

Merged
merged 4 commits into from
Dec 20, 2024
Merged

[typing] update prefect.futures #16381

merged 4 commits into from
Dec 20, 2024

Conversation

zzstoatzz
Copy link
Collaborator

@zzstoatzz zzstoatzz commented Dec 13, 2024

related to #16292

updates typing of wait and DoneAndNotDoneFutures

Copy link

codspeed-hq bot commented Dec 13, 2024

CodSpeed Performance Report

Merging #16381 will not alter performance

Comparing fix-wait-typing (bbb393b) with main (581510a)

Summary

✅ 3 untouched benchmarks

@zzstoatzz zzstoatzz added the development Tech debt, refactors, CI, tests, and other related work. label Dec 13, 2024
@zzstoatzz zzstoatzz marked this pull request as ready for review December 13, 2024 23:47
@zzstoatzz zzstoatzz changed the title [wip] [typing] update prefect.futures [typing] update prefect.futures Dec 14, 2024
Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@zzstoatzz zzstoatzz merged commit 6f5d463 into main Dec 20, 2024
37 checks passed
@zzstoatzz zzstoatzz deleted the fix-wait-typing branch December 20, 2024 23:43
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]
Copy link
Contributor

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
Copy link
Contributor

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] = []
Copy link
Contributor

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.

Suggested change
states: list[State] = []
states: list[State[Any]] = []

devinvillarosa pushed a commit that referenced this pull request Dec 24, 2024
devinvillarosa pushed a commit that referenced this pull request Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Tech debt, refactors, CI, tests, and other related work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants