Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRIO100 does not detect async context managers #9855

Closed
CoolCat467 opened this issue Feb 6, 2024 · 1 comment · Fixed by #9859
Closed

TRIO100 does not detect async context managers #9855

CoolCat467 opened this issue Feb 6, 2024 · 1 comment · Fixed by #9859
Assignees
Labels
bug Something isn't working

Comments

@CoolCat467
Copy link

Noticed this in my work on python-trio/trio#2947, it appears that TRIO100 does not detect async context managers.

minimal.py:

import trio

async def test_reentry_doesnt_deadlock() -> None:
    # Regression test for issue noticed in GH-2827
    # The failure mode is to hang the whole test suite, unfortunately.
    # XXX consider running this in a subprocess with a timeout, if it comes up again!

    async def child() -> None:
        while True:
            await trio.to_thread.run_sync(trio.from_thread.run, trio.sleep, 0, abandon_on_cancel=False)

    with trio.move_on_after(2):
        async with trio.open_nursery() as nursery:
            for _ in range(4):
                nursery.start_soon(child)
> ruff check minimal.py --isolated --select TRIO
minimal.py:12:5: TRIO100 A `with trio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint.
> ruff --version
ruff 0.2.1
@charliermarsh charliermarsh added the bug Something isn't working label Feb 6, 2024
@charliermarsh
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants