Skip to content

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

Merged
charliermarsh merged 4 commits intoastral-sh:mainfrom
dylwil3:async100-skip-yield-in-context-manager
Aug 15, 2024
Merged

[flake8-async] Do not lint yield in context manager cancel-scope-no-checkpoint (ASYNC100)#12896
charliermarsh merged 4 commits intoastral-sh:mainfrom
dylwil3:async100-skip-yield-in-context-manager

Conversation

@dylwil3
Copy link
Copy Markdown
Collaborator

@dylwil3 dylwil3 commented Aug 14, 2024

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

Closes #12873.

@github-actions
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator 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
Copy Markdown
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
Copy Markdown
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
@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