-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Refactor: Inject Client #12258
Refactor: Inject Client #12258
Conversation
✅ Deploy Preview for prefect-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
woof my fears are realized: the in-function imports were for avoiding circular imports |
I've changed the devex to be |
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.
🔥 Thank you!
Prefect's
inject_client
decorator wraps an async function with anOptional[PrefectClient]
kwarg, injecting an inferred or new client if none is provided.This PR refactors the
get_or_infer_client
logic to a separate function. This will makes type-hinting much easier. Getting static type checkers to acknowledge that@inject_client
is providing a default to an optional kwarg is hard.Consider the
_get_variable_by_name
utility, which fails basic type hinting:With
get_or_infer_client
factored out, we recover better type hinting:Checklist
maintenance
,fix
,feature
,enhancement
,docs
.For new functions or classes in the Python SDK: