-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[flake8-async] Do not lint yield in context manager cancel-scope-no-checkpoint (ASYNC100)
#12896
[flake8-async] Do not lint yield in context manager cancel-scope-no-checkpoint (ASYNC100)
#12896
Conversation
|
// in the caller yielded to. | ||
// https://flake8-async.readthedocs.io/en/latest/rules.html#async100 | ||
// https://github.com/astral-sh/ruff/issues/12873 | ||
if with_stmt.body.iter().any(|stmt| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic here only traverses the direct children of a with statement but, for example, not the statements in an if body. Is this intentional? If not, consider using the StatementVisitor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not intentional, thank you! I tried using any_over_body
instead. Unless I'm misunderstanding, that's slightly faster since it gets to stop traversing the tree as soon as a yield
is found, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with that method. I'll take a look tomorrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, correct usage of any_over_body
!
6f646d2
to
faf47ae
Compare
For compatibility with upstream, treat
yield
as a checkpoint inside cancel scopes.Closes #12873.