[syntax-errors] Detect yield from inside async function#20051
[syntax-errors] Detect yield from inside async function#20051ntBre merged 10 commits intoastral-sh:mainfrom
yield from inside async function#20051Conversation
|
Thanks for working on this! It looks like there are a few unrelated test failures in the CI results. The inline tests also produce a couple of files that have to be checked in. Let me know if you need help resolving either of those issues! |
|
(labeling this as |
|
Have updates to fix the CI, however this test is failing |
AlexWaygood
left a comment
There was a problem hiding this comment.
Thanks for the PR!
I fixed the issue in ty's tests (just a pre-existing bug in the test that your PR exposed!), and checked in the snapshot for your new test.
It looks like there are a bunch of changes to existing ruff_python_parser snapshots too, though, and I'm not sure if they're correct. Could you take a look? You can review the changes to the snapshots locally by running cargo test -p ruff_python_parser and then running cargo insta review. cargo insta review will prompt you to take a look at each snapshot change and see whether it looks good or not -- if it does, you can accept the change; if it doesn't, you know you have some more work to do on the PR to fixup the logic somewhere :-)
|
I have a couple of doubts : first: while reviewing snapshots I found this Here this second: should I commit all the updated snapshots ? Thank you |
|
Hii @ntBre, |
|
I think the test failures are running into a limitation of our inline parser error test suite: ruff/crates/ruff_python_parser/tests/fixtures.rs Lines 530 to 532 in 32cb863 You can see there that we've hard-coded ruff/crates/ruff_python_parser/tests/fixtures.rs Lines 534 to 541 in 32cb863 So I think you'll also need to add a real implementation of Along these lines, we usually add two other kinds of tests for these errors since they depend on ruff's and ty's implementations of ruff/crates/ruff_linter/src/linter.rs Lines 1185 to 1190 in 32cb863 and in ty:
Yes, once you get a set of snapshot failures that look correct, you'll need to commit the updated snapshots to pass the tests in CI. |
|
@ntBre thank you for guiding this PR! I have updated it accordingly , could you please take a look. |
|
I'll try to take a look soon! It looks like the representation of AST nodes changed slightly last week (#20028), you might need to rebase/merge main and update your snapshots once more to get CI passing. There's also one small clippy suggestion. |
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
Signed-off-by: 11happy <[email protected]>
8acc790 to
e80ffb4
Compare
|
have rebased it, CI should pass now |
Signed-off-by: 11happy <[email protected]>
|
Updated the snapshot & fixed the clippy suggestion as per new CI results. |
|
ntBre
left a comment
There was a problem hiding this comment.
Thanks! This looks great overall, we just need to delete the old rule implementation to avoid duplicate diagnostics.
There was a problem hiding this comment.
It looks like we're getting duplicate diagnostics. I think there should be some existing PLE1700 code that we need to delete now that it's being detected and reported as a syntax error:
We should be able to delete this function and any callers.
Signed-off-by: 11happy <[email protected]>
|
Hi maintainers, please let me know if any further input or changes are required from my end for this PR. Thank you |
yield from inside async function
…20051) <!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary This PR implements https://docs.astral.sh/ruff/rules/yield-from-in-async-function/ as a syntax semantic error ## Test Plan <!-- How was it tested? --> I have written a simple inline test as directed in [https://github.com/astral-sh/ruff/issues/17412](https://github.com/astral-sh/ruff/issues/17412) --------- Signed-off-by: 11happy <[email protected]> Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Brent Westbrook <[email protected]>
Summary
This PR implements https://docs.astral.sh/ruff/rules/yield-from-in-async-function/ as a syntax semantic error
Test Plan
I have written a simple inline test as directed in #17412