ruff icon indicating copy to clipboard operation
ruff copied to clipboard

[`ruff`] Implement missing `await` for coroutine (`RUF028`)

Open mikeleppane opened this issue 1 year ago • 6 comments

Summary

Detect never-awaited coroutines

This rule only applies to simple scenarios. We need to be quite conservative on how to handle coroutines. Because there are many situations in which the programmer does not want to evaluate/await a coroutine but instead use the actual coroutine object.

Closes https://github.com/astral-sh/ruff/issues/9833

Test Plan

cargo test

mikeleppane avatar Feb 09 '24 13:02 mikeleppane

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

github-actions[bot] avatar Feb 09 '24 14:02 github-actions[bot]

CodSpeed Performance Report

Merging #9911 will not alter performance

Comparing mikeleppane:rule(RUF028)/detect-unused-await (0275ffd) with main (8ec5627)

Summary

✅ 30 untouched benchmarks

codspeed-hq[bot] avatar Feb 09 '24 14:02 codspeed-hq[bot]

Thanks for contributing!

It looks like the ecosystem checks are showing some false positives e.g. https://github.com/apache/airflow/blob/48bfb1a970f5b47ba1b385ad809b8324923ddf3e/tests/providers/google/cloud/hooks/test_dataflow.py#L1956 — could you look into those?

zanieb avatar Feb 09 '24 23:02 zanieb

Thanks for contributing!

It looks like the ecosystem checks are showing some false positives e.g. https://github.com/apache/airflow/blob/48bfb1a970f5b47ba1b385ad809b8324923ddf3e/tests/providers/google/cloud/hooks/test_dataflow.py#L1956 — could you look into those?

Thanks! Good catch.

mikeleppane avatar Feb 10 '24 07:02 mikeleppane

This rule fits into ruff as a suspicious rule. I think we should rename the rule to never-awaited-coroutines so that allow(never-awaited-coroutines) reads better.

MichaReiser avatar Apr 05 '24 10:04 MichaReiser

Hi, any update on when this will be released?

akselerando avatar Apr 30 '24 12:04 akselerando