Deprecate @sync_compatible in favor of @async_dispatch#22142
Conversation
Closes the final step of #15008. Emits a PrefectDeprecationWarning when `sync_compatible` is applied, directing authors to define an explicit async function dispatched via `@async_dispatch`. Core no longer uses the decorator; the warning is scoped-ignored in the test suite (which still exercises the decorator directly) with one test asserting it fires. Depends on #22140 (prefect-azure) and #22141 (prefect-dbt) — the last source usages — merging first. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Merging this PR will not alter performance
Comparing Footnotes
|
`src/prefect/settings/_types.py` was not regenerated when `runner.auto_install_dependencies` was added in #22116, leaving the `SettingAccessor` alias stale. This unblocks pre-commit and `test_setting_accessor_type_alias_is_current` on this branch. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 64fea4305a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| generate_deprecation_message, | ||
| ) | ||
|
|
||
| warnings.warn( |
There was a problem hiding this comment.
Migrate remaining internal sync_compatible uses first
With the warning emitted as soon as the decorator is applied, any module that still uses Prefect's own @sync_compatible will warn during import rather than only when a third-party author decorates new code. I checked repo-wide with rg and there are still source decorators in src/integrations/prefect-azure/prefect_azure/blob_storage.py and src/integrations/prefect-dbt/prefect_dbt/cloud/jobs.py, so importing those integration modules will now emit many PrefectDeprecationWarnings and will fail for users or CI running with deprecation warnings as errors. Please defer this warning or land the integration migrations in the same change.
Useful? React with 👍 / 👎.
|
This pull request is stale because it has been open 14 days with no activity. To keep this pull request open remove stale label or comment. |
Final step of #15008. Emits a
PrefectDeprecationWarningwheneversync_compatibleis applied, directing authors to the explicit async +@async_dispatchpattern.Important
Depends on #22140 (prefect-azure) and #22141 (prefect-dbt) merging first — those remove the last source usages of
@sync_compatible. Holding this as draft until they land.details
@sync_compatible async def foo), so it targets the code author rather than end users who merely call a decorated function.generate_deprecation_messagehelper withstart_date="May 2026"⇒ "removal after Nov 2026". Imported lazily insidesync_compatibleto keepasyncutilsfree of heavier imports.tests/utilities/test_asyncutils.py. A scopedfilterwarningsignore (matching the existingRunner.*deprecation entries) keeps those behavior tests green under the suite'sfilterwarnings = ["error"], and a newtest_sync_compatible_emits_deprecation_warningasserts the warning actually fires.sync_compatible(their remaining references are docstring mentions only), so none are affected.