File tree Expand file tree Collapse file tree 1 file changed +20
-16
lines changed
crates/ruff_python_parser/src Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -682,23 +682,27 @@ impl SemanticSyntaxChecker {
682
682
expr : & Expr ,
683
683
kind : YieldOutsideFunctionKind ,
684
684
) {
685
- if !self . in_function_scope && !self . source_type . is_ipynb ( ) {
686
- // test_err yield_outside_function
687
- // yield 1
688
- // yield from 1
689
- // await 1
690
-
691
- // test_ok yield_inside_function
692
- // def f():
693
- // yield 1
694
- // yield from 1
695
- // await 1
696
- Self :: add_error (
697
- ctx,
698
- SemanticSyntaxErrorKind :: YieldOutsideFunction ( kind) ,
699
- expr. range ( ) ,
700
- ) ;
685
+ if self . in_function_scope {
686
+ return ;
687
+ }
688
+ if self . source_type . is_ipynb ( ) && matches ! ( kind, YieldOutsideFunctionKind :: Await ) {
689
+ return ;
701
690
}
691
+ // test_err yield_outside_function
692
+ // yield 1
693
+ // yield from 1
694
+ // await 1
695
+
696
+ // test_ok yield_inside_function
697
+ // def f():
698
+ // yield 1
699
+ // yield from 1
700
+ // await 1
701
+ Self :: add_error (
702
+ ctx,
703
+ SemanticSyntaxErrorKind :: YieldOutsideFunction ( kind) ,
704
+ expr. range ( ) ,
705
+ ) ;
702
706
}
703
707
704
708
/// Add a [`SyntaxErrorKind::ReboundComprehensionVariable`] if `expr` rebinds an iteration
You can’t perform that action at this time.
0 commit comments