8000 Internal error: `while` loop inside a `fail_after()` leaks `ArtificialStatement` · Issue #295 · python-trio/flake8-async · GitHub
[go: up one dir, main page]

Skip to content

Internal error: while loop inside a fail_after() leaks ArtificialStatement #295

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

Closed
Zac-HD opened this issue Sep 24, 2024 · 0 comments · Fixed by #296
Closed

Internal error: while loop inside a fail_after() leaks ArtificialStatement #295

Zac-HD opened this issue Sep 24, 2024 · 0 comments · Fixed by #296

Comments

@Zac-HD
Copy link
Member
Zac-HD commented Sep 24, 2024

Consider the following code, extracted and simplified from something you might actually want to run:

import trio

async def fn(timeout):
    with trio.fail_after(timeout):
        while True:
            if condition():
                return
            await trio.sleep(1)

We want to get some linter warnings, but actually see an internal error:

Traceback (most recent call last):
  File ".../flake8", line 8, in <module>
  ...
  File ".../flake8_async/visitors/visitor91x.py", line 773, in leave_While_body
    any_error |= self.error_91x(err_node, stmt)
  File ".../flake8_async/visitors/visitor91x.py", line 455, in error_91x
    assert not isinstance(statement, ArtificialStatement)
AssertionError

I'm very glad that we have this assertion to help detect the problem! cc @jakkdl for a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0