Skip to content

TRIO115 false positive with with sleep(var) where var starts as 0 #9935

@mikenerone

Description

@mikenerone

Ruff 0.2.1

The following snippet illustrates a TRIO115 false positive when sleep() is passed a variable whose initial value was 0, but changes later in a loop construct. Similar to #9934, this is already fixed in flake8-trio. This seems to be strongly indicating that recent fixes to flake8-trio need to be ported in general.

import trio

async def main() -> None:
    sleep = 0
    for _ in range(2):
        # ↓↓↓↓↓ TRIO115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)`
        await trio.sleep(sleep)
        sleep = 10

trio.run(main)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions