astral-sh / astral-sh/ruff

`ASYNC119`: allow some context managers and async context managers to contain `yield` statements

Open
#25,652 4 comments 0 reactions 0 assignees View on GitHub
needs-decision rule
Dominant language
Rust
Stars
49.6k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
458

Description

### Summary

Context managers such as `contextlib.suppress` currently trigger `ASYNC119` when a `with` block using an instance of its surrounds `yield` statements in an async generator function. However, there is no risk that an exception is propagated at the wrong time in this case because that is literally what `contextlib.suppress` handles. Either it should be added to an exclude list, or users should be allowed to configure classes that bypass this rule.

Contributor guide

Open the contributing guide

Research direction

Locate the ASYNC119 rule implementation and its tests, then inspect how context managers surrounding yield statements are detected. Decide whether the completed change should cover contextlib.suppress, configurable classes, or both, and add tests demonstrating the accepted behavior without weakening the rule for other context managers.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.