python-trio / flake8-async

Highly opinionated linter for Trio code
https://flake8-async.readthedocs.io
MIT License
17 stars 2 forks source link

`ASYNC100` should not trigger for blocks containing a `yield` statement #224

Closed Zac-HD closed 3 months ago

Zac-HD commented 3 months ago
@contextmanager
def fail_at_with_error(deadline, error):
    with trio.move_on_at(deadline) as cancel_scope:  # noqa: ASYNC100
        yield cancel_scope
    if cancel_scope.cancelled_caught:
        raise error

As of the current version, the noqa comment is suppressing an error. However, the move_on_at() could be triggered by checkpoints syntactically outside this block, so I think we should avoid false alarms and allow this case.