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

ASYNC100 no longer triggers on context managers containing a yield #228

Merged
merged 2 commits into from
Apr 3, 2024

Conversation

jakkdl
Copy link
Member

@jakkdl jakkdl commented Apr 1, 2024

I .. don't know why I didn't open a PR when pushing this branch. fixes #224

@jakkdl
Copy link
Member Author

jakkdl commented Apr 1, 2024

oh that's why, it wasn't finished x)

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jakkdl
Copy link
Member Author

jakkdl commented Apr 3, 2024

eval_files/noqa.py was using yields + async100 + async911 to test noqa functionality, relying on context managers with yields in them to raise async100. So changed it to using returns (and async910) instead

Comment on lines +119 to +122
# Don't trigger for blocks with a yield statement
async def foo():
with trio.fail_after(1):
yield
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. This should indeed be allowed by ASYNC100...

...but now I'm wondering about a non-optional rule to warn when you yield across a known cancelscope and the function isn't a context-manager, because that really doesn't work. Probably not worth the trouble, since njs and I are planning to get runtime enforcement, the rule would have many missed alarms, and ASYNC900 covers it anyway for people who care.

@Zac-HD Zac-HD merged commit d29a33d into python-trio:main Apr 3, 2024
9 of 10 checks passed
@jakkdl jakkdl deleted the async100_yield branch April 4, 2024 11:01
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 should not trigger for blocks containing a yield statement
2 participants