Skip to content

Deprecate @sync_compatible in favor of @async_dispatch#22142

Open
zzstoatzz wants to merge 2 commits into
mainfrom
deprecate-sync-compatible-15008
Open

Deprecate @sync_compatible in favor of @async_dispatch#22142
zzstoatzz wants to merge 2 commits into
mainfrom
deprecate-sync-compatible-15008

Conversation

@zzstoatzz

Copy link
Copy Markdown
Collaborator

Final step of #15008. Emits a PrefectDeprecationWarning whenever sync_compatible is applied, directing authors to the explicit async + @async_dispatch pattern.

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
  • The warning fires at decoration time (once per @sync_compatible async def foo), so it targets the code author rather than end users who merely call a decorated function.
  • Uses the existing generate_deprecation_message helper with start_date="May 2026" ⇒ "removal after Nov 2026". Imported lazily inside sync_compatible to keep asyncutils free of heavier imports.
  • After the two migration PRs, core has zero source usages — the only place that still applies the decorator is its own test file, tests/utilities/test_asyncutils.py. A scoped filterwarnings ignore (matching the existing Runner.* deprecation entries) keeps those behavior tests green under the suite's filterwarnings = ["error"], and a new test_sync_compatible_emits_deprecation_warning asserts the warning actually fires.
  • No integration test suites import sync_compatible (their remaining references are docstring mentions only), so none are affected.

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]>
@codspeed-hq

codspeed-hq Bot commented May 28, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 8 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing deprecate-sync-compatible-15008 (64fea43) with main (f7d76f2)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

`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]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant