async-zero-sleep (ASYNC115)
Derived from the flake8-async linter.
Fix is always available.
What it does
Checks for uses of trio.sleep(0)
or anyio.sleep(0)
.
Why is this bad?
trio.sleep(0)
is equivalent to calling trio.lowlevel.checkpoint()
.
However, the latter better conveys the intent of the code.
Example
Use instead:
Fix safety
This rule's fix is marked as unsafe if there's comments in the
trio.sleep(0)
expression, as comments may be removed.
For example, the fix would be marked as unsafe in the following case: