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

[flake8-async] Do not lint yield in context manager cancel-scope-no-checkpoint (ASYNC100) #12896

Merged

Conversation

dylwil3
Copy link
Contributor

@dylwil3 dylwil3 commented Aug 14, 2024

For compatibility with upstream, treat yield as a checkpoint inside cancel scopes.

Closes #12873.

Copy link
Contributor

github-actions bot commented Aug 14, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

// 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| {
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Member

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!

@charliermarsh charliermarsh force-pushed the async100-skip-yield-in-context-manager branch from 6f646d2 to faf47ae Compare August 15, 2024 00:58
@charliermarsh charliermarsh enabled auto-merge (squash) August 15, 2024 00:58
@charliermarsh charliermarsh merged commit e4c2859 into astral-sh:main Aug 15, 2024
17 checks passed
@dylwil3 dylwil3 deleted the async100-skip-yield-in-context-manager branch August 15, 2024 02:27
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 this pull request may close these issues.

ASYNC100 does not match upstream flake8-async
3 participants