From 9683375e883602414ff42dd44f9979a316ced570 Mon Sep 17 00:00:00 2001 From: karpetrosyan Date: Tue, 7 Nov 2023 16:46:29 +0400 Subject: [PATCH] Fix doc --- .../rules/flake8_trio/rules/unneeded_sleep.rs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_trio/rules/unneeded_sleep.rs b/crates/ruff_linter/src/rules/flake8_trio/rules/unneeded_sleep.rs index d2038d70de1d2a..828dd4404ed4b2 100644 --- a/crates/ruff_linter/src/rules/flake8_trio/rules/unneeded_sleep.rs +++ b/crates/ruff_linter/src/rules/flake8_trio/rules/unneeded_sleep.rs @@ -6,27 +6,27 @@ use ruff_text_size::Ranged; use crate::checkers::ast::Checker; /// ## What it does -/// Checks for trio functions that should contain await but don't. +/// Checks for the while loop, which waits for the event. /// /// ## Why is this bad? -/// Some trio context managers, such as `trio.fail_after` and -/// `trio.move_on_after`, have no effect unless they contain an `await` -/// statement. The use of such functions without an `await` statement is -/// likely a mistake. +/// Instead of sleeping in a loop waiting for a condition to be true, +/// it's preferable to use a trio. Event. /// /// ## Example /// ```python +/// DONE = False +/// /// async def func(): -/// with trio.move_on_after(2): -/// do_something() +/// while not DONE: +/// await trio.sleep(1) /// ``` /// /// Use instead: /// ```python +/// DONE = trio.Event() +/// /// async def func(): -/// with trio.move_on_after(2): -/// do_something() -/// await awaitable() +/// await DONE.wait() /// ``` #[violation] pub struct TrioUnneededSleep;