Skip to content

[ruff] Clarify intentional async contexts for unused-async (RUF029) - #26641

Merged
ntBre merged 1 commit into
astral-sh:mainfrom
Joosboy:docs-ruf029-async-context
Jul 9, 2026
Merged

[ruff] Clarify intentional async contexts for unused-async (RUF029)#26641
ntBre merged 1 commit into
astral-sh:mainfrom
Joosboy:docs-ruf029-async-context

Conversation

@Joosboy

@Joosboy Joosboy commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

This updates the RUF029 documentation to mention that an async function can sometimes be intentional even when it does not directly await anything.

One example is an async test or callback that needs to run inside an async execution context, such as code that uses a ContextVar.

The docs now point users toward either adding a real await when appropriate or disabling the rule for that specific function when the async boundary is intentional.

Refs #23196.

Test Plan

  • cargo dev generate-docs
  • cargo fmt --check --all
  • PATH="$PWD/target/debug:$PATH" uv run --only-group dev --locked python scripts/check_docs_formatted.py
  • PATH="$PWD/target/debug:$PATH" uv run --only-group dev --locked prek run --files crates/ruff_linter/src/rules/ruff/rules/unused_async.rs
  • cargo test -p ruff_linter rules::ruff::tests::rules::rule_unusedasync_path_new_ruf029_py_expects

@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre July 8, 2026 17:14
@ntBre ntBre added the documentation Improvements or additions to documentation label Jul 9, 2026
@ntBre ntBre changed the title [ruff] Clarify intentional async contexts for unused-async (RUF029) [ruff] Clarify intentional async contexts for unused-async (RUF029) Jul 9, 2026

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks reasonable to me, thank you!

@ntBre
ntBre enabled auto-merge (squash) July 9, 2026 23:06
@ntBre ntBre closed this Jul 9, 2026
auto-merge was automatically disabled July 9, 2026 23:09

Pull request was closed

@ntBre ntBre reopened this Jul 9, 2026
@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre July 9, 2026 23:10
@ntBre
ntBre enabled auto-merge (squash) July 9, 2026 23:10
@ntBre
ntBre merged commit 04d831a into astral-sh:main Jul 9, 2026
84 of 92 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants