Skip to content

Commit

Permalink
Fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
karpetrosyan committed Nov 7, 2023
1 parent 4d3e48b commit 9683375
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions crates/ruff_linter/src/rules/flake8_trio/rules/unneeded_sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9683375

Please sign in to comment.