-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[flake8-bugbear] Catch yield expressions within other statements (B901)
#21200
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6f840cd
feat: implement semantic syntax error for async generator with return
11happy 91d57b1
refactor: use visitor based approach
11happy bd766dc
refactor: use visit_stmt & have siilar impl to original B901
11happy c809537
convert to B901 error
11happy 8ab6926
fix: clippy error
11happy 5b311f3
remove unreferenced snapshot
11happy 3679a0f
remove previous
11happy 39bbb4d
use visitor to ensure nested cases are also detected
11happy 68890ea
remove unreferenced snapshot
11happy f0f2423
revert return in generator
11happy dd1ce45
remove tests
11happy 26980d9
restore syntax error test case
ntBre 43f39bf
update ok comments
ntBre a8b0068
we don't need the Stmt::Expr branch anymore
ntBre 2590a74
use updated visitor code in B901 too
ntBre 868b973
update test names
ntBre 5387492
update new test names and spacing
ntBre abc6971
Merge branch 'main' into return_in_async_generator
ntBre fe9fb9a
Merge branch 'main' into return_in_async_generator
ntBre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor: use visit_stmt & have siilar impl to original B901
Signed-off-by: 11happy <soni5happy@gmail.com>
- Loading branch information
commit bd766dc7f51db4fb101a6bf65732f33db84a33d4
There are no files selected for viewing
23 changes: 22 additions & 1 deletion
23
crates/ruff_linter/resources/test/fixtures/semantic_errors/return_in_async_generator.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,24 @@ | ||
| async def gen(): | ||
| yield 1 | ||
| return 42 | ||
| return 42 | ||
|
|
||
| def gen(): #ok | ||
| yield 1 | ||
| return 42 | ||
|
|
||
| async def gen(): #ok | ||
| yield 1 | ||
| return | ||
|
|
||
| async def gen(): | ||
| yield 1 | ||
| return foo() | ||
|
|
||
| async def gen(): | ||
| yield 1 | ||
| return [1, 2, 3] | ||
|
|
||
| async def gen(): | ||
| if True: | ||
| yield 1 | ||
| return 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.